0

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?>}
}
David Buck
  • 3,752
  • 35
  • 31
  • 35
Alex
  • 11
  • 1

1 Answers1

0

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
  }
}
  • And if you're wondering how to turn Daml values into JSON, [this is the docs page for that](https://docs.daml.com/json-api/lf-value-specification.html). – Gary Verhaegen Apr 05 '21 at 12:28