Code Monkey home page Code Monkey logo

Comments (3)

ak3n avatar ak3n commented on May 3, 2024

Please specify the content type with -H "Content-Type: application/json". That should help.

from plutus-apps.

locallycompact avatar locallycompact commented on May 3, 2024

This still doesn't work.

lc@aiur ~/S/g/i/plutus-apps (main)> curl -X POST http://localhost:9080/api/contract/activate -H "Content-Type: application/json" -d '{ "caID": "Currency", "caWallet": { "getWallet": 1 }}'
Error in $.caID: parsing ContractExample.ExampleContracts failed, expected Object, but encountered String⏎   

from plutus-apps.

ak3n avatar ak3n commented on May 3, 2024

It doesn't work in a different way this time.

The error tells us that "Error in $.caID: parsing ContractExample.ExampleContracts failed, expected Object, but encountered String". It expects an object for caID as ExampleContracts is defined as a sum type:

data ExampleContracts = UniswapInit
                      | UniswapOwner
                      | UniswapUser Contracts.Uniswap.Uniswap
                      | GameStateMachine
                      | PayToWallet
                      | AtomicSwap
                      | Currency
                      | PrismMirror
                      | PrismUnlockExchange
                      | PrismUnlockSto
                      | PingPong
                      | WaitForTx TxId

and we are passing a string. So we should to pass an object.

Aeson (JSON library for Haskell) deals with sum types via "tag" attributes. The correct one will be"caID": {"tag": "Currency"}.

But also getWallet was changed a bit recently and should be updated as well. The correct one will be "caWallet": { "getWalletId": "872cb83b5ee40eb23bfdab1772660c822a48d491"}.

And the final working curl command is

curl -v -s -H "Content-Type: application/json" -X POST -d '{"caID": {"tag": "Currency"}, "caWallet": { "getWalletId": "872cb83b5ee40eb23bfdab1772660c822a48d491"}}' http://localhost:9080/api/contract/activate

from plutus-apps.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.