All devices URL works sometimes, doesn't work other times


#1

Got a strange issue happening.
I’m hitting https://developer-api.nest.com with my newly acquired access_token.

When I use Postman it gets the data every time. However, when I use Ruby (or even cURL) it doesn’t work every time. By not working I mean it just returns an empty string. Sometimes it returns data, but most of the time it just returns that empty string.

Here is a GIST of my code example: https://gist.github.com/rushingfitness/ad609468fc462a15e665f762adbbd165

Someone please help me figure out what I’m doing wrong!


#2

Thanks for sending the link, I was able to reproduce it using your cURL sample.
For cURL testing, please add the -L flag, which will follow redirects in the response. Also adding -v is helpful to show you the headers and other details.
Example:
curl -v -L
-H “Content-Type: application/json”
-H “Authorization: Bearer c.YOUR_TOKEN_HERE”
-X GET “https://developer-api.nest.com/

For the ruby sample, you would need to find a library or add code that handles the redirects, by checking if the HTTP response code is 307. The Redirect URL to follow will be in the response header key “Location”.

Here’s a link that might help with some sample code, close to what you have.

Hope this works for you.