I am trying to create an Android app to interact with an embedded application running on a Spark Core Wi-Fi module. The Spark Core is a Wi-Fi module that runs Arduino code on its included ARM processor (see https://www.spark.io).
Communication to this module is done via the "Spark Cloud", a site that acts as an intermediary between your web-based app and the embedded program running on the ARM core. It securely passes GETs and POSTs between your app and your specific Spark Core module using the ID of your specific Spark Core, and your private authentication token (both of which you get as part of connecting your core to Spark Cloud).
I have been able to use App Inventor's “call web.Url” and "when web.GotText" components to get data off of the Spark Core in combination with Spark's recommended GET:
https://api.spark.io/v1/devices/[your specific Core ID]/[Variable holding data to be returned]?access_token=[Your authentication ID]
But I have not been able to get the POST to
work. The Spark Core POST includes a function name that will be called on
the ARM, and a string to be passed to that function. A set of data is
returned. Their recommended POST syntax is:
https://api.spark.io/v1/devices/[your specific Core ID]/[function to be called] -d access_token=[Your authentication ID] -d "args=[string to be passed]"
If executed utilizing curl in a command window on windows, both GET and POST work fine. So how to get this POST to work on App Inventor?
Hopefully this is not a dumb question - I have
written many Arduino programs but am not that knowledgeable on web programming
like GET and POST. I tried to use the "call web.PostText"
component, putting the above POST into the text box. But I get an
"Error 1109 - the specific URL is invalid:".
Any thoughts or pointers to helpful sites
appreciated. Found nothing on the Spark
Thanks for ideas, especially pointing out that -d is just for curl. Obviously not going to work with that in there.
I attached the blocks in attachment as suggested (the Spark Core ID and API Token hidden in the red boxes). I may be in over my head. Will see if I can implement any of the suggestions. And will post similar question on the Spark Core forum - thought my app issue was with use of App Inventor but it may be more likely that it is how to make the proper POST to Spark Cloud.. Thanks again.