Hi all,
I try to figure out, how the RPC (using ‘curl’) really works. I found some documentation under ‘https://mongoose-os.com/docs/mongoose-os/userguide/rpc.md’ and implemented the example, i.e. the RPC-Function ‘Sum’.
Then I tried the given examples:
REST:
The particulars on how to pass the parameters to the client of your choice running on the command interpreter of your choice are… particular.
‘-d’ in curl is an option to send using POST. If you send with curl via POST, you have to send a JSON object. Generally, that JSON object will be stringified. You need to pass the object after the -d as a single block; that will depend on how your shell will separate parameters and whether it likes or not the single quotes '. What you did was to avoid both the single quotes and the space that was there because otherwise that space will break the object in most environments. It works as is in my system.
If you put the parameters along with the URL you are using GET and here instead of sending a JSON object you will send parameters the GET way. So, different parameters have to be separated with the ampersand sign &.
Some command interpreters have a special meaning for this sign, so, it is common to use single quotes to escape the sequence and so the shell does not interpret it. The example works on my system if I use double quotes instead of single quotes.
Personally I’ve found mDash a really nice place to test RPC as it formats it correctly for you and even gives you the curl commands it you want to perform the commands from command line