Could you help me debug a React `exerciseByKey` call?
- gyorgybalazsiOP 1
Could anybody help me with this?
This is my component (written by not me but a React developer), with the function call:
const ButtonLA4 = (props) => { const { children } = props; let date = new Date() let newId = Date.now() const ledger = useLedger(); const buttonLa4Function = async () =>{ try { await ledger.exerciseByKey( Main.Setup.Setup_MegrendelestIndit, "ledger-party-beszerzes", { eszkozMegnevezes: "Eszkoz-abcd", megrendelo: "ledger-party-megrendelo", megrendeloAdatok: { megrendeloNev: "Megrendelonev-abcd", megrendeloCusman: "MegrendeloCusman-1234" }, kosarszam: "Kosarszam-1234" } ); } catch (err) { alert(`Error of exerciseByKey with choice = Main.Setup.Setup_MegrendelestIndit:\n${err}`); } } return ( <a href="javascript:SubmitForm('form2')" onClick={buttonLa4Function}> <div className="beszer-button-la beszer-border-1px-thunder"> <div className="beszer-lorem-ipsum-i115131 beszer-opensans-normal-white-14px">{children}</div> </div> </a> ); }I get the following errors:
POST http://localhost:3000/v1/exercise 404 (Not Found)
Cannot POST /v1/exercise
The acting party (the party on behalf of which I issue the command) is allocated on the ledger, and is specified with party id and access token in the DamlLedger component of the React code.
The acting party can see the contract
Main.Setupin Navigator, and the contract has the choiceSetup_MegrendelestIndit.The contract has the key I specify in the call:
-- SETUP START template Setup with kancellaria : Party beszerzes : Party penzugy : Party helpdesk : Party szallito : Party where signatory kancellaria key kancellaria : Party maintainer key -- A Zebra beszerzés partyként rögzíti a megrendelést controller beszerzes can nonconsuming Setup_MegrendelestIndit : ContractId Megrendeles with eszkozMegnevezes : Text megrendelo : Party megrendeloAdatok : MegrendeloAdatok kosarszam : Text do megrendelesIdopontja <- getTime let folyamatAzonosito = sha256 $ show eszkozMegnevezes <> show megrendelesIdopontja folyamatAdatok = FolyamatAdatok with folyamatAzonosito eszkozMegnevezes gyariszam = None szamlaSzama = None .. megrendelesiAdatok = MegrendelesiAdatok with megrendelesIdopontja kosarszam .. create Megrendeles with .. -- SETUP ENDI guess I don’t notice something trivial, can you help me to find it?
- cocreature 2
The JSON API will never produce a 404 for a call to
/v1/exercise. Looking at the port 3000, it seems like you might be trying to connect via the webpack dev server. My guess would be that the proxy from that to the JSON API is somehow misconfigured.I recommend taking a look at how this is setup for create-daml-app and see what is different in your setup.
- gyorgybalazsi 1
Thanks, that helped, I have a different error now which is closer to the successful ledger update, I post it in a different question.

