GET weather API data in a web request, for color changing bulb?


Woohoo! This worked. I moved the bulb and set color into the execute every minute and now it’s working great. I’ll mess around to find a way to leave the bulb off if it’s already off.

Thanks for everyone’s help.


The command:
Every X minutes, do Y
Is one of the few triggers that does not run top to bottom. It only executes what is inside the block at the time of execution. The rest of the code outside is ignored.


Thanks. Just getting the hang of the terminology and how it all works.


So this worked until recently. It appears that it cannot read the response with $response. Any ideas on how to write out a json expression to pull data?


Check the below thread… it might be related.


Are there any errors at > Live Logging? It looks like this API responds quickly enough to not be affected by the linked timeout issue, at least from your past logs. If there are no errors, try logging $httpStatusCode – is it in the 300’s?


Oh nope, this is something new. webCoRE is sending a very wrong request header:
Accept: application/x-www-form-urlencoded

That doesn’t make sense, the Accept header tells the server what type of response it should send back. It should not be set to match the request. I don’t see any code in webCoRE doing this, SmartThings is defaulting that to the request type but I can override it. That’s an illogical default :confused:

If you need this quickly and want to apply a code patch, line 3301 in the webCoRE Piston smart app sets the requestContentType and needs the following contentType line added (this code is not specific to you, JSON is the only response that webCoRE understands and “prefers” but anything is acceptable)

requestContentType: requestContentType,
contentType: 'application/json, */*;q=0.9',  // add this line

Web requests may fail with 406 status code due to incorrect Accept header

My god, you’re a genius. This now works and my lights finally turn color and my outdoor lights finally turn off when it’s light outside. I couldn’t be certain, but I recently updated webcore and this is what must have messed up everything. Thanks so much.

Should I post this as a bug, though I don’t understand the issue beyond what you typed. :slight_smile:


I’ll write up a bug and link this task. It was convenient that your API URL was still in the thread!