Help on Cloud command CURL

Dear forum,

I am facing a problem, which I try to solve . Unfortunately my knowledge in curl is limited. I am following an example of Particle of turning a led ON and OFF using the curl in command line.

I would like to implement this to a RESTrequest can someone advice me what would be the BaseURL to use for the post method?

I am using .Net to send this command with POST method using a button.

The Particle example CURL is : curl https://api.particle.io/v1/devices/0123456789abcdef/led
-d access_token=123412341234
-d params=on

My .Net button sends with POST method the following but it does not work, do you know what I am writing wrong?

https://api.particle.io/v1/devices/0123456789abcdef/led?access_token=123412341234&params=on

Regards
John

The -d options to curl put the data in the POST body, not the URL, as text data of type application/x-www-form-urlencoded data.

So your URL would be: https://api.particle.io/v1/devices/0123456789abcdef/led

And the POST body data would be:

access_token=123412341234&params=on

Hi , thanks for the fast reply,

I only have one place to put the URL, it is not like HTML5 which I can seperate them . In my example I have to put the URL to a string and then post it.

Lets say you use a Visual Basic programming , how should you send the http post?

Because when I use the GET , to read an analogue value my URL is only one.

https://api.particle.io/v1/devices/0123456789abcdef/analogue?access_token=123412341234

Hi ! I have just found out how to do it!

thank you very much!

It was a mistake in the parameters value.

1 Like

Yes, but that's a GET request, which can be handled as a singe string. A POST request needs to be treated differently, for good reasons. How to use that with visual basic can be found here, if anyone's still interested: Make HTTP requests with the HttpClient - .NET | Microsoft Learn

1 Like