When do I need to submit the package ID as part of the template id for JSON API transactions?
- gyorgybalazsiOP 2
Sometimes I have to specify the template id for JSON API transactions in the full format, if I fail to submit the package id, I get an error message:
<package ID>:<module name>:<template name>Sometimes the short version is enough:
<module name>:<template name>wich is described in the documentation (HTTP Request).
What makes the difference?
If I have to submit the package id, what is the easiest way to get it?
- cocreature 4
You have to submit the package id if the pair
(moduleName, templateName)is not unique among all DAML-LF packages uploaded to the ledger. I would generally recommend that you always include the package id for production applications but for testing and debugging it’s of course totally fine to omit it.As for getting access to the package id, if you can I would recommend to use the JavaScript codegen which will automatically include this on all requests. If that is not an option for whatever reason, you can use
daml damlc inspect-jar --json .daml/dist/mydar.darto print out the package id. Themain_package_idin there is the one of your current project but you also get the package id of your dependencies. If you want to extract it automatically, something likejqor your favorite JSON library will do the job. - gyorgybalazsi
Thank you!
- gyorgybalazsi 1
What if the
daml buildanddaml deploycommands returned the main package id? - cocreature 2
I prefer having it in a separate command with machine-readable output as opposed to trying to add more output to a command that does not produce machine readable output. That just means people will start relying on the current output format of
daml buildand parse it viagrepor whatever else which is guaranteed to break at some point.