Getting CONTRACT_NOT_FOUND in json api when exercising a just created contract

What am I doing wrong or missing?

  • Created a contract in json api (a POST), using Postman, with url: http://127.0.0.1:7575/v1/create

  • results in the create has: “contractId”: “0092d49a64f3a24a0f9c6db91714b84a093fdb74d53702164d30a83c8eb5e82b07ca001220f28c51b1dffe87bc14031f38b6dd236749ba0beb53d3b9073533036ee0a98cb4”

  • but when exercising (a POST with url of http://127.0.0.1:7575/v1/exercise) with this below, i get the error.

{
“templateId”: “Budget:BudgetProposal”,
“contractId”: “0092d49a64f3a24a0f9c6db91714b84a093fdb74d53702164d30a83c8eb5e82b07ca001220f28c51b1dffe87bc14031f38b6dd236749ba0beb53d3b9073533036ee0a98cb4”,
“choice”: “Accept”,
“argument”: {}
}

  • the error snippet is:
    “errors”: [
    “NOT_FOUND: CONTRACT_NOT_FOUND(11,f5e0f537): Contract could not be found with id 0092d49a64f3a24a0f9c6db91714b84a093fdb74d53702164d30a83c8eb5e82b07ca001220f28c51b1dffe87bc14031f38b6dd236749ba0beb53d3b9073533036ee0a98cb4”
    ]

  • when i do a /v1/fetch, the contract returns the correct values. In Navigator, I also verified the contract with that ID, and is not archived.

Any suggestions to try? Are the values in the json input correct or missing something else?
Thnx in advance.

The two main options I see are:

  1. Something else is archiving the contract in parallel between you checking /v1/fetch and calling /v1/exercise. Calling /v1/fetch again should confirm that.
  2. Your command submission does not have the right to see that contract. The token you use to fetch it should also work for the exercise so try reusing that if you’re not already. If you are using the same token already, check that you’re not setting actAs and/or readAs in the meta field.

Thank you @cocreature !

So it wasn’t #1, as it wasn’t archived yet and I confirmed this in /fetch and in the Navigator.

I tried #2, and after reviewing the exercise command, the choice is coded to create an object using a different template and this template needed an additional Party not in the template for the create command. So I had to get a new token with an additional item in the “actAs” field. That did the trick.

Edited: I suppose the error message could be better, hopefully in upcoming versions, to be more specific and closer to the proper error to debug. Thanks.

The fact that you cannot tell apart a contract that doesn’t exist from one you cannot see is by design: you should not be able to learn about the existence of a contract if you don’t have access to it. Replying with something different from a CONTRACT_NOT_FOUND would indirectly give a party access to information they are not privy too.