A contract has two signers. I want to archive the contract through JsonAPI. How should the token be assembled?
- skylornaOP
- WallaceKelly
Hi, @skylorna.
Your first screenshots show that in the first case, you did not have sufficient authorization.
Your second screenshots show that in the second case, after fixing the authorization issue, you ran into a second issue, summarized by “malformed request.”
I don’t know for sure, but I would start by examining the payload JSON that you are sending to the endpoint. It might be that the payload JSON does not match the expected input for the endpoint you are calling.
- skylorna
Hi @WallaceKelly this is my Json ,I archived all other contracts with only one signer using this json, only contracts with 2 signers won’t work
- WallaceKelly
Everything looks correct in your screenshots. I tried to reproduce the issue on my machine, but was not able to. Below are the steps I took. Perhaps this will help us identify what might be going on…
Using Daml 2.5.1.
daml new ArchiveTestcd ArchiveTestdaml studio- Edit the Main.daml to require two signatories. (See code below.)
daml start- In Navigator, grab the ids for Alice, Bob, the template, and the contract.
- At http://jwt.io, create a JWT payload with Alice’s and Bob’s ids. (See payload below.)
- In Postman, create a GET request to
http://localhost:7575/v1/exercise. Use the encoded JWT token for the authorization, bearer token. Set the body to the JSON payload. (See code below.)
Main.daml
module Main where import Daml.Script type AssetId = ContractId Asset template Asset with issuer : Party owner : Party name : Text where ensure name /= "" signatory issuer, owner -- added owner observer owner choice Give : AssetId with newOwner : Party controller owner do create this with owner = newOwner setup : Script AssetId setup = script do -- user_setup_begin alice <- allocatePartyWithHint "Alice" (PartyIdHint "Alice") bob <- allocatePartyWithHint "Bob" (PartyIdHint "Bob") aliceId <- validateUserId "alice" bobId <- validateUserId "bob" createUser (User aliceId (Some alice)) [CanActAs alice] createUser (User bobId (Some bob)) [CanActAs bob] -- user_setup_end submitMulti [alice, bob] [alice, bob] do -- modified createCmd Asset with issuer = alice owner = bob name = "TV"JWT payload
{ "https://daml.com/ledger-api": { "ledgerId": "sandbox", "applicationId": "foobar", "actAs": ["Alice::1220da75f38e5e1646005009f38663d6a5f852e340f00b986ca1d3664a1de899ca90","Bob::1220da75f38e5e1646005009f38663d6a5f852e340f00b986ca1d3664a1de899ca90"] } }JSON payload
{ "templateId": "3907bff048d6a5f1f7011cdde7cdd32dbd96895533abde443716945373d3a8a2:Main:Asset", "contractId": "00e9ba1dd24395ca912a7e604c769a7c1f27d99215649fcd8e7405b71f9435d356ca011220b68a1ab794074167f5c80c432cf06174e45a6e96f25ccbcba66ec1964f932fad", "choice": "Archive", "argument": {} }Here is the result on my machine:
Can you think of anything that is different in your case?
- skylorna
@WallaceKelly canton
I upload dar file to canton-enterprise-2.3.4
and use DAML SDK 2.5.0 start JsonAPI service
The contract is historical data, not sure about the SDK version that generated the dar file - skylorna
@WallaceKelly
Another difference is that my two signers are on different participant nodes - Mate_Varga
I just spotted that the exp field of your token is 1666076941, which is a timestamp that points to October in the last year.
- skylorna
- Mate_Varga
First you should check the JSON API Server logs if there are more details about it, then the logs produced by your participant node.
- skylorna
I found this error message in the log
Malformed request err-context:{location=TransactionProcessingSteps.scala:281, message=Confirmation request creation failed, reason=ParticipantAuthorizationError(PAR::participant2::12208660a72f… does not host MC::1220782025913f21ae3df5b87f75015329f9b5c1d7f5173f68c6ef54fee330f0ead1 or is not active.)}HK is participant2‘s party, MC is participant1’s party, HK and MC both the signatories,and I want to Archive the contract by use participant1‘s JsonAPI
- skylorna
- cocreature 1
skylorna:At present, it seems that the contract is signed by two parties on the two participant nodes, but there is no dar file for this contract on participant1 nodes.
That shouldn’t be possible. How did you verify that the contract has both parties as signatories? You could try uploading the DAR again. Uploading the same DAR multiple times is harmless so that shouldn’t cause any issues.
- skylorna 2
It may be that participant1 has been artificially deleted. There is no such dar file on participant1 and the contract cannot be found, so it should be an illegal operation that caused this problem. Thank you.








