How to create token to use HTTP Json Api server in the canton?

Hi Team,

I have Canton network in the VMs. I have run the participant1 and domain in VM1 and participant2 in VM2 natively. I have started the HTTP Json api server in both the VMs. I have deployed smart contract called GenerateInputs module GenerateInputs where

template GenerateInputs
with
user : Party
dealId : Text
month : Text
year : Text
value : [Text]
where
signatory user
observer user

key user : Party
maintainer key


-- Define the SubmitGenerateInputs choice
choice UpdateGenerateInputsValue : ContractId GenerateInputs
  with
    newValue : Text
  controller user
  do
    archive self
    create this with value = newValue :: value

In the VM2, I have enable the party called Alice using the following command, participant2.parties.enable("Alice", waitForDomain=DomainChoice.All). In the postman, http://127.0.0.1:7575/v1/create {

“templateId”: “GenerateInputs:GenerateInputs”,
“payload”: {
“user” : “Alice”,
“dealId” : “testdeal1”,
“month” : “01”,
“year” : “2024”,
“value” : “30000.00”
}
} when i click sent, it throws error missing OAuth2.0 bearer token error message. so using online jwt, in the payload, i have given {
“https://daml.com/ledger-api”: {
“ledgerId”: “participant2”,
“applicationId”: “foobar”,
“actAs”: [
“Alice”
]
}
} this. but i got the error, {
“errors”: [
“INVALID_PARTY_IDENTIFIER(8,c94dc321): The given party is not a valid Canton party identifier: Unable to parse party: Invalid unique identifier Alice with missing namespace.”
],
“status”: 400
}. How to create token and how to access http json api server ? can anyone suggest how to build the typescript app and how to use http json api ?

^ That’s the key info there. Alice is just a display name. Parties have identifiers of the form alice::abc123 where abc123 is just a random hex string called the “namespace”. Try the daml ledger list-parties command to find out the full identifier of the parties you’ve allocated.

1 Like

Hi,

How to create token and how to access http json api server ? can anyone suggest how to build the typescript app and how to use http json api ?

The docs here walk through setting up an example, complete with TypeScript and HTTP JSON API.

That would be discussed in the more advanced docs here, on the topic of authorization.