Making a web request with an authorization token


I am trying to run a piston that gets data from a server.
The URL I’m doing the GET is:[StationID]?token=[MyTokenID]

When I do this in curl, works just fine… but I don’t know how to do it in WebCore. Simply putting that in for the URL value returns me with a 406. So how do I set this up in webcore to make the http request?


Does it work from a browser?


I don’t think I’ve ever seen a 406 but assuming the API returns JSON it suggests the Accept: header isn’t appropriate.

I can’t remember what the current behaviour of webCoRE is with these headers but it might be that setting the request type to JSON helps (I know it is the wrong content type and irrelevant on a GET, but SmartThings used to default one to the other).


Yes, it works from a browser


I changed it to a PUT and tried JSON and CUSTOM and both of those return a 405


I just sent the request through and got the following:

GET /test?token=[MyTokenID] HTTP/1.1
Accept: application/x-www-form-urlencoded
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
User-Agent: AHC/1.0
X-B3-Sampled: 0
X-B3-Spanid: 017ef2fdb3223b0d
X-B3-Traceid: 017ef2fdb3223b0d

I’m guessing the application/x-www-form-urlencoded is my problem since I’m using JSON? How do I fix that?

Edit: I figured out I could change it to a type POST and request body type = Value->Custom and Request content type = Value->Application/json. I see in reqeust catcher, it’s now coming ing as an Content type application/json, but I’m getting a 405 response code still.


Well… stupid me… Figured it out…

It’s been a while since I’ve logged into webcore and when I did, it said I had an outdated version of webcore. I logged into the IDE and updated from master, and published.

My logs for this piston were rolling:
║WARNING: Results may be unreliable because the parent app’s version (v0.3.114.20220203) is newer than the child app’s version (v0.3.113.20210203). Please consider updating both apps to the same version.

Figured it was no big deal and I’d figure it out later. Well, later rolled around and I discovered I never Published the WebCoRE Piston so it was on v0.3.113 (just like the warning said). I published to update to v0.3.114 and now it’s working just fine… I’m not going to claim to understand why…but I’m working now.

Thank for the help.