JSON API contract creation on sandbox gives HTTP 400

Hi team,

I’m getting bad request response with JSON API contract creation. Error message refers data type issue of DA.Set and JsonArray.

Appreciate your help.

DAML version - 1.16.0

DAML template

template LedgerTest
with
owner : Party
obs : Set Party
slotKey : Int
version: Int
timeStamp : Time
where
signatory owner
observer obs

Request Body

{

“templateId”: “5d448c13ba2ed7dea9c6b97a4abf690d6f78c605fac96bb098e60b6dbdbf81d3:Main:LedgerTest”,

“payload”: {

“owner”: “Alice”,

“obs”: [],

“slotKey”: 1,

“version”: 1,

“timestamp”: “2021-10-20T03:06:56.326Z”

},

“meta”: {

“commandId”: “f7a21b8c-982d-4ec7-89ac-9e27468e03cb”

}

Response

{

“errors”: [

"JsonError: spray.json.DeserializationException: Can’t read [] as DamlLfRecord 97b883cd8a2b7f49f90d5d39c981cf6e110cf1f1c64427a28a6d58ec88c43657:DA.Set.Types:Set, wrong number of record fields (expected 1, found 0)."

],

“status”: 400

}

Thanks,
Thejaswani

Hi @Theja, take a look at REST JSON Specification - #2 by cocreature which tackles the same topic.

To summarize, Set is a record wrapper around Map so you need something like {"map": []} for an empty Set instead of [].

1 Like

Thank you @cocreature works now :+1:t2:

1 Like