Hi everybody,
In these strange times, I try to send some request to my Thymio robot with Snap!.
I successfully do with curl
on mac OS X those 2 actions but I can't do them with Snap!
- the first one
curl "http://localhost:3000/nodes/thymio-II/temperature"
the answer : [315]
- the second one
curl -H 'Content-Type: application/octet-stream' --data-ascii "$(cat coursework.aesl)" -X PUT http://localhost:3000/nodes/thymio-II
This action sends a program to the robot. And I see that it works (the robot reacts well).
In Snap! I tried this :
As you can see, it does not work.
How can I do that please ?
Thanks a lot for any help and take care of you.
Hi @nathalierun ,
I think your only problem is you are running Snap! over https and your Thymio app mounts a http server.
Easy fix. Use http://extensions.snap.berkeley.edu/snap.html (it is a "normal" Snap! but over http) and all your http calls will run ok.
Joan
Hi @jguille2,
No, this is not the problem. I have exactly the same problem with Redirecting to Snap! .
Anyway, if you write http://localhost... instead of http://127.0.0.1 you don't have problem with http calls in Snap! Build Your Own Blocks.
Ah!
But to do the same you are doing with your browser (just typing an URL), use the simple url block, not the Web services library.
Check this... and later (maybe you have other issues) we can talk about those blocks and their headers ("cors" and others...)
Joan
Isn't "liste" object an empty list reporter in localized Snap?
Header is required.
E.g.
Thank you @dardoro. It works :
@jguille2 I know that I can use the url
block to do this.
But I try to understand how GET and PUT work. In fact, I need to PUT a file in the robot.
With curl
, I have this command line :
curl -H 'Content-Type: application/octet-stream' -d "$(cat explorateurV6.aesl)" -X PUT http://localhost:3000/nodes/40753
where 40753 is the node of one of my two robots Thymio-II.
(I'm trying to do this because I would be able to send two different behaviours inside two robots Thymio-II ; it works in the command line using curl
).
And I try this in Snap! :
It doesn't work.
Just a remark : the option -d
in curl
mean --dumb. I guess that my problem is here? I saw during some researches that the file as to be a Blob object (I hope it makes sens).
With the AdvancedRestClient Application, I have this :
And the result with the robot : https://nathalierun.net/depotLibre/Videos/IMG_8508.webm
Hi everybody,
I finally resolved my problem, with a local instance of Snap!.
Thank you again @dardoro and @jguille2 for your help.
Fine @nathalierun,
I haven't any Thymio and I can't test it...but if you need later the online version, we can see it again.
I guess there is a "CORS" problem. You can see the "javascript console" of your browser and look at its http responses.
Joan
Ok @jguille2, I come back to you to make it work with an online version, if it's possible. Effectively, I saw in the javascript console that there is a "CORS" problem.
Here are the messages in the javascript console when I click on this block :
-
Local version of Snap! (it works : the file is correctly sent to the robot and the robot reacts well)
-
online version of Snap! (nothing appens)
-
On the extensions version Redirecting to Snap! (it works)