# Using JSON API with CANTON

**URL:** <https://forum.canton.network/t/using-json-api-with-canton/4671>\
**Category:** App Development\
**Created:** [June 3, 2022, 10:47pm UTC](https://forum.canton.network/t/using-json-api-with-canton/4671 "2022-06-03T22:47:56Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![Bernardo](https://avatars.discourse-cdn.com/v4/letter/b/c0e974/32.png) [@Bernardo](https://forum.canton.network/u/Bernardo)\
**Post date:** [June 7, 2022, 2:22pm UTC](https://forum.canton.network/t/using-json-api-with-canton/4671/21 "2022-06-07T14:22:03Z")

</div>

> [@Gary\_Verhaegen](#):
>
> when you tell the domain to upload a DAR to all participants, the DAR does not get added to participant1. But when you explicitly upload to participant1, that works, so participant1 itself is not broken.

I updated the domain conf file, and added both participants:

> ```
> canton {
> domains {
> mydomain {
> storage.type = memory
> admin-api {
> port = 10017
> address = 192.168.61.129 // is the default value if omitted
> }
> public-api {
> port = 10018
> address = 192.168.61.129 // is the default value if omitted
> }
> }
> }
> 
> remote-participants {
> participant1 {
> admin-api {
> port = 5012
> address = 192.168.61.128
> }
> ledger-api {
> port = 5011
> address = 192.168.61.128
> }
> }
> }
> 
> remote-participants {
> participant2 {
> admin-api {
> port = 5012
> address = 192.168.61.130
> }
> ledger-api {
> port = 5011
> address = 192.168.61.130
> }
> }
> }
> }
> 
> ```

This is why now i am able to upload the dar and it is visible to participant1 and 2

> [@Gary\_Verhaegen](#):
>
> (Moving forward, we’ve still not solved the `daml start` issue either, but one thing at a time.)

I just use the daml start --script-option --output-file=parties.json to get the Party ids, in order to create contracts with json api. I need the Party id for alice and bob that are specified in that file.

Thank you for your time, hope Moritz can help me

---

<div class="post-metadata">

**Author:** ![Gary\_Verhaegen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gary_verhaegen/32/81_2.png) [@Gary\_Verhaegen](https://forum.canton.network/u/Gary_Verhaegen)\
**Post date:** [June 7, 2022, 2:29pm UTC](https://forum.canton.network/t/using-json-api-with-canton/4671/22 "2022-06-07T14:29:06Z")

</div>

> [@Bernardo](#):
>
> Thank you for your time, hope Moritz can help me

It’s not entirely clear what problem you’re now facing. You tell us the dar upload is now working; can you explain what you still need help with? What error are you now seeing?

---

<div class="post-metadata">

**Author:** ![Bernardo](https://avatars.discourse-cdn.com/v4/letter/b/c0e974/32.png) [@Bernardo](https://forum.canton.network/u/Bernardo)\
**Post date:** [June 7, 2022, 2:34pm UTC](https://forum.canton.network/t/using-json-api-with-canton/4671/23 "2022-06-07T14:34:20Z")

</div>

The dar is uploaded to participant1 but when i try to create contracts with participant1 using JSON API i get 404 error

[![](https://canada1.discourse-cdn.com/flex028/uploads/daml/original/2X/e/ed941961987e78c1994622c88d90db7f2e182d3f.png) ](https://canada1.discourse-cdn.com/flex028/uploads/daml/original/2X/e/ed941961987e78c1994622c88d90db7f2e182d3f.png)

---

<div class="post-metadata">

**Author:** ![Gary\_Verhaegen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gary_verhaegen/32/81_2.png) [@Gary\_Verhaegen](https://forum.canton.network/u/Gary_Verhaegen)\
**Post date:** [June 7, 2022, 2:42pm UTC](https://forum.canton.network/t/using-json-api-with-canton/4671/24 "2022-06-07T14:42:33Z")

</div>

That’s a weird error essage, but let’s assume for a second it may be related to the `daml start` issue. When you run `daml start`, by default it will run a local sandbox and run its commands against that. I’m not seeing anything in your `daml.yaml` or your CLI arguments to overwrite that default behaviour. This means that the parties you have created with your script get created on the sandbox created by daml start, and not on the participants in your domain.

In order to create the parties, you’ll need to run the script against the appropriate participant (I imagine that, as you have two participants, you probably want to create different parties in each one). You can do that with the `daml script` command, which, unlike `daml start`, does not start its own sandbox but instead runs against the participant you point it to (run `daml script --help` for details). You’ll need to first compile the DAR containing your script with `daml build`, then run something like:

```plaintext
daml script --dar PATH_TO_DAR \
            --ledger-host 192.168.61.128 \
            --ledger-port 5011 \
            --output-file PARTIES_PART1.json \
            --script-name module:function \
            --input-file INPUT_PART1.json

```

with uppercase things changed to appropriate values (you may or may not need an `input-file`, depending on the details of your script).

---

<div class="post-metadata">

**Author:** ![Bernardo](https://avatars.discourse-cdn.com/v4/letter/b/c0e974/32.png) [@Bernardo](https://forum.canton.network/u/Bernardo)\
**Post date:** [June 7, 2022, 2:56pm UTC](https://forum.canton.network/t/using-json-api-with-canton/4671/25 "2022-06-07T14:56:29Z")

</div>

It worked! Thank you very much! 😀

The correct party id was the participant’s!

---

<div class="post-metadata">

**Author:** ![Gary\_Verhaegen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gary_verhaegen/32/81_2.png) [@Gary\_Verhaegen](https://forum.canton.network/u/Gary_Verhaegen)\
**Post date:** [June 7, 2022, 2:58pm UTC](https://forum.canton.network/t/using-json-api-with-canton/4671/26 "2022-06-07T14:58:49Z")

</div>

Happy to help!

Would you mind marking the question as resolved? You can always open a new thread if you have further questions down the line.

[Previous page](https://forum.canton.network/t/using-json-api-with-canton/4671.md?page=1)
