HTTP Post always gives unauthorized

Running ESP8266 where i have

thing[“led2”] << [](pson& in){
digitalWrite(2, in ? LOW : HIGH);
};

I’m unable to get the HTTP post to work through Rest API from third party service. I’ve tried it through Chrome application “Postman” and from Android’s Tasker app. Both gives me allways “401 Unauthorized”.

This is the HTTP Post that i’m using:
https://api.thinger.io/v2/users/MyUserName/devices/MyDevice/led2?authorization=MyTokenCode{“in”:true}

I’ve made a token for MyDevice to access all of my recourses and with that token i’m succesfully reading data from ESP8266 with HTTP GET, so I’m assuming the token is correct.

I can’t figure out what I’m doing wrong?

With Tasker I did as in this example but without any luck:
https://community.thinger.io/t/http-post-using-tasker/57

Not sure if you are appending the resource input (to turn on the led) to the token device (as shown in the url you provided). If this is your case, then you are providing a bad token key.

You must call the HTTP request with header Content-Type: application/json and set the HTTP body with: {"in":true} to turn on the led, or {"in":false}.

The remaining URL seems to be fine.

Thanks alvarolb, you were right!
I got it up and running now.
The main reason why I didn’t get the Tasker to work was the feature in tasker: Every time you make a change to tasker action, you need to close tasker and start it again. Otherwise it will run the action with old values.

1 Like

Hi. Sorry to ask you, but I was reading the examples over the other threads and I don’t know if i’m not understanding something.

I want to control a motor sending on / off directly from thebrowser using the api
https://api.thinger.io/v2/users/MyUserName/devices/MyDevice/led29?authorization?

Is that possible ? only with a link ?

Thank you :wink: