Exercise a choice via HTTP JSON API

130 Views Asked by At

Exercise a choice via HTTP JSON API

-> The choice has 'party'

choice Something: Optional (ContractId Request)
    with    
        party: Party
    controller party
        do
            ......
        

What do i input in ARGUMENTS in my HTTP JSON API body in POSTMAN to exercise this choice in POST http://localhost:7575/v1/exercise

{
    "templateId" : ,
    "contractId" : ,
    "choice": "Something",
    "argument":{<WHAT TO TYPE HERE?>}
}
1

There are 1 best solutions below

1
David Martins On

The arguments attribute is populated with the the parameters you define in a choice.

Example:

module Foo where

template Foo
  with
    party : Party
  where
    signatory party

    controller party can
      Bar: ()
        with
          someText : Text
          someInt : Int
        do
          {- 
          ...
          -}
          return ()

This would translate into the following request body:

{
  "templateId": "Foo:Foo",
  "contractId": <contract_id>,
  "choice": "Bar",
  "argument":{
    "someText": "text",
    "someInt":  1
  }
}