I’m able to query the data via Daml JSON-API but when I’m trying to create a new contract or exercise a choice via contractID getting error in sandbox:
[http-json-ledger-api-akka.actor.default-dispatcher-74] INFO com.daml.http.Endpoints - Responding to client with HTTP 401 Unauthorized, context: {instance_uuid: “7b260c35-be20-4617-9ee8-e7d7077f3d6f”, request_id: “09baad21-8f2b-4ee0-8349-c7422197f750”}
Token: const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwczovL2RhbWwuY29tL2xlZGdlci1hcGkiOnsibGVkZ2VySWQiOiJlZjY1YmI4NS1hY2JmLTQ0NzYtYmI1MS1iNTE3ZGY1ZmUyNGMiLCJhcHBsaWNhdGlvbklkIjoidGVzdE1hcmtldCIsImFjdEFzIjpbIkJPTlkiXX19.vj2t3Xr3ISTURsi7d-QEhjEbobBS6JvdADe4ltQE8xc";
the token is derived via jwt.io passing this as payload:
{
"https://daml.com/ledger-api": {
"ledgerId": "ef65bb85-acbf-4476-bb51-b517df5fe24c",
"applicationId": "testMarket",
"actAs": [
"BONY"
]
}
}
Sample Payload:
Exercise via contractID:
contractData = {
"templateId": "Main.BusinessObjects.Bond:Bond",
"contractId": "#0:0",
"choice": "IssueBond",
"argument": {
"_isin": "ISIN-8",
"_issuer": "BONY",
"_investor": "TESLA",
"_quantity": 999.99
}
}
Axios Call
axios.post(`http://localhost:7575/v1/exercise`, {
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + token
},
data: contractData
})
Creation of new contract:
contractData = {
"templateId": "Main.BusinessObjects.Bond:Bond",
"payload": {
"isin": "ISIN-6",
"issuer": "BONY",
"investor": "TESLA",
"quantity": 999.99
}
}
Axios Call
axios.post(`http://localhost:7575/v1/create`, {
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + token
},
data: contractData
})
Why am I getting this error for exercising and creation but not for query? How can I debug why authorization is failing?