Postman Sample Request - Create API
Hi,
Is there any sample code available for calling the create API [POST /data/:ledgerId/v1/create] using Postman?
I am trying to call the CreateQuoteRequest choice from the BuyerRole and need some help.
Stripped out Workflow
Operator -> Create Network
Operator -> ExerciseCmd BuyerInvitation on Network - Buyer1
Operator -> ExerciseCmd SellerInvitation on Network- Seller1
Operator -> ExerciseCmd CreateProductCard on Network- PID : 100
Buyer1 -> AcceptBuyerInvitation
Seller1 -> AcceptSellerInvitation
Buyer1 -> ExerciseCmd CreateQuoteRequest with quoteInfos [PID:100, Seller 1]
Seller1 -> Accept QuoteRequest
Buyer1 -> AcceptQuote
(below is stripped out model)
Main.daml
-- Copyright (c) 2020 The DAML Authors. All rights reserved.
-- SPDX-License-Identifier : Apache-2.0
module Main where
import Prelude hiding (submit)
--------------------------------------------------------------------
-- Data Types
--------------------------------------------------------------------
-- Product
data Product = Product
with
productId : Text
productName : Text
modelNumber : Text
productDetails : Text
productURL : Text
deriving (Eq, Show)
-- Items in a Quote
data QuoteRequestItem = QuoteRequestItem
with
product : Product
productQty : Int
deriving (Eq, Show)
-- PO terms
data PurchaseOrderTerms = PurchaseOrderTerms
with
buyerAgent : Party
deriving (Eq, Show)
-- Shipping information
data QuoteInfo = QuoteInfo
with
quoteRefNum : Text
dueDate : Date
buyer : Party
seller : Party
items : [QuoteRequestItem]
deriving (Eq, Show)
----------------------------------------------------------
-- Model
----------------------------------------------------------
----------------------------------------------------------
-- User Role
----------------------------------------------------------
template UserRole
with
userParty : Party
role : Text
where
signatory userParty
----------------------------------------------------------
-- Network
----------------------------------------------------------
template Network
with
operator : Party
where
signatory operator
controller operator can
controller operator can
-- Create Buyer
nonconsuming InviteBuyer : ContractId BuyerInvitation -- persist/not single use as need multiple
with
buyer : Party
do
create BuyerInvitation with operator, buyer
-- Create Seller
nonconsuming InviteSeller : ContractId SellerInvitation -- persist/not single use as need multiple
with
seller : Party
do
create SellerInvitation with operator, seller --, publicPartyRole
-- Create Product
nonconsuming CreateProductCard : ProductCard -- persist/not single use as need multiple
with
product : Product
do
pId <- create ProductCard with operator, product
fetch pId
----------------------------------------------------------
-- Product item
----------------------------------------------------------
template ProductCard
with
product : Product
operator : Party
where
signatory operator
key (operator, product):(Party, Product)
maintainer key._1
----------------------------------------------------------
-- BuyerInvitation
----------------------------------------------------------
template BuyerInvitation
with
buyer : Party
operator : Party
where
signatory operator
controller buyer can
AcceptBuyerInvitation : ContractId BuyerRole
do
create UserRole with userParty = buyer, role = "BUYER"
create BuyerRole with buyer, operator
----------------------------------------------------------
-- SellerInvitation
----------------------------------------------------------
template SellerInvitation
with
seller : Party
operator : Party
-- publicPartyRole : Party
where
signatory operator
controller seller can
AcceptSellerInvitation : ContractId SellerRole
do
create UserRole with userParty = seller, role = "SELLER"
create SellerRole with seller, operator
----------------------------------------------------------
-- Buyer Actions
----------------------------------------------------------
template BuyerRole
with
buyer : Party
operator : Party
where
signatory operator, buyer
key (buyer):(Party)
maintainer key
controller buyer can
nonconsuming CreateQuoteRequest : [ContractId QuoteRequest]
with
quoteInfos : [QuoteInfo]
do
mapA (\quoteInfo -> create QuoteRequest with quoteInfo) quoteInfos
nonconsuming InviteBuyerAgent : ContractId BuyerAgentInvitation
with
buyerAgent : Party
do
create BuyerAgentInvitation with buyer, buyerAgent
----------------------------------------------------------
-- BuyerAgentInvitation
----------------------------------------------------------
template BuyerAgentInvitation
with
buyer : Party
buyerAgent : Party
where
signatory buyer
controller buyerAgent can
AcceptBuyerAgentInvitation : ContractId BuyerAgentRole
do
create UserRole with userParty = buyerAgent, role = "BUYER_AGENT"
create BuyerAgentRole with buyer, buyerAgent
----------------------------------------------------------
-- BuyerAgent Role
----------------------------------------------------------
template BuyerAgentRole
with
buyer : Party
buyerAgent : Party
where
signatory buyer, buyerAgent
----------------------------------------------------------
-- Seller Actions
----------------------------------------------------------
template SellerRole
with
seller : Party
operator : Party
where
signatory operator, seller
----------------------------------------------------------
-- RFQ
----------------------------------------------------------
template QuoteRequest
with
quoteInfo : QuoteInfo
where
signatory quoteInfo.buyer
controller quoteInfo.seller can
AcceptQuoteRequest : ContractId Quote
with
quotedPrice : Decimal
quotedDate : Date
do
create Quote with quoteInfo, quotedPrice, quotedDate
RejectQuoteRequest : ()
do
return ()
controller quoteInfo.buyer can
CancelQuoteRequest : ()
do
return ()
----------------------------------------------------------
-- Accepted Quote
----------------------------------------------------------
template Quote
with
quoteInfo : QuoteInfo
quotedPrice : Decimal
quotedDate : Date
where
signatory quoteInfo.seller, quoteInfo.buyer
-- controller quoteInfo.buyer can
-- AcceptQuote : ContractId PurchaseOrder
-- with
-- purchaseOrderTerms : PurchaseOrderTerms
-- do
-- create PurchaseOrder with quote=this, purchaseOrderTermsHi @Arvind_Rao. I’m not aware of any examples, but I have seen people use Postman to interact with the API so I know it works. What have you tried so far? Are you experiencing any errors?
Thanks, no worries figured it out (looking at the documentation)
Team was running into issues in calling the APIs’ directly, so wanted to see the bare request/response so they would implement that in their reactjs code.