2

I finished smart contract tutorial, and it worked well. Now I'm trying to send same action as cleos push action hello hi '["bob"]' -p user@active in tutorial by using RPC API, cause need to implement push in other language(not JS). Currently, I've found that I need to generate JSON as abi-bin for now, so tried to send like:

curl --header "Content-Type: application/json" \
  --data '{
  "code": "hello",
  "action": "hi",
  "args": {
    "name": "user",
    "type": "account_name"
  }
}' \
  --request POST http://localhost:8888/v1/chain/abi_json_to_bin

but it failed. It returns:

{
   "code":500,
   "message":"Internal Service Error",
   "error":{
     "code":3015014,
     "name":"pack_exception",
     "what":"Pack data exception",
     "details":[]
   }
}

...and in chain, it prints:

2018-10-19T10:18:47.006 thread-0   http_plugin.cpp:581           handle_exception     ] Exception Details: 3015014 pack_exception: Pack data exception
Missing 'user' in variant object
{"f":"user"}
thread-0  abi_serializer.cpp:389 _variant_to_binary

{"type":"hi","var":{"name":"user","type":"account_name"}}
thread-0  abi_serializer.cpp:410 _variant_to_binary

{"type":"hi","var":{"name":"user","type":"account_name"}}
thread-0  abi_serializer.cpp:426 _variant_to_binary
'{"name":"user","type":"account_name"}' is invalid args for action 'hi'     code 'hello'. expected '[{"name":"user","type":"name"}]'
{"args": {"name":"user","type":"account_name"},"action":"hi","code":"hello","proto": [{"name":"user","type":"name"}]}
thread-0  chain_plugin.cpp:1737 abi_json_to_bin
code: hello, action: hi, args: {"name":"user","type":"account_name"}
{"code":"hello","action":"hi","args":   {"name":"user","type":"account_name"}}
thread-0  chain_plugin.cpp:1743 abi_json_to_bin

Could somebody give me a guide for correct request form?

Thanks.

4
  • don't you need to pass some authorization to the http api the same way you pass via cleos with -p? it'd help if you mentioned how it failed i.e. what error
    – confused00
    Commented Oct 19, 2018 at 9:50
  • @confused00 thanks! I just update detail logs... Commented Oct 19, 2018 at 10:24
  • @confused00 I added -p, but it returns same error. Commented Oct 22, 2018 at 2:17
  • did you ever solve this? I'm having a similar issue
    – ekkis
    Commented Feb 1, 2019 at 23:40

1 Answer 1

0

It looks to me as if the args command should be an array, even though it only has one element.

Try replacing this part:

  "args": {
    "name": "user",
    "type": "account_name"
  }

with this:

  "args": [{
    "name": "user",
    "type": "account_name"
  }]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.