1
Solved

HTTP request not working and not clear why

I am trying to make an HTTP request to https://developer-api.nest.com in my task.  I have a working auth token and can make my request work fine in Postman and/or CURL on my PC.  But when I try the exact same request in a tasker task I get a 401.

I have included the following in the HTTP Request action for headers:

Authentication:Bearer %ACCESS_TOKEN

Am I configuring this wrong?  I followed the directions (separate name and value with a colon and no extra spaces).  Authentication is even one of the examples in the doc and this looks exactly like it so it should be working right?  And again, I have tested this exact request in Postman without issue so I know I have a valid access token that should be working.  Invalid access token is not the issue here.

On a related note, is there any way to see the details of the exact HTTP request that went out?  The log doesn't seem to show that and I can't see any obvious way to get to that information.  I'm sure I could find something like fiddler to help me see all network traffic coming out of my phone while running the task but it would be great if tasker provided a way to log out the exact HTTP requests its making for debugging.

1 reply

Ok I figured it out.  The reason this is happening is because the Nest API is returning a 307 Temporary Redirect response.  It looks like the HTTP Request action tries to automatically follow redirects for GET requests in this case but when it does it does not pass along my authorization header. 

I didn't realize Nest was returning a redirect since Postman does automatically follow redirects and does pass along the authorization header when it does, that's why Postman worked and Tasker didn't.  When I tried a PUT request to the same API with tasker then it actually returned me the redirect response so that's how I figured it out.  When I swapped out the original API with the redirect one everything worked fine.

So I guess the real bug here is that Tasker does not pass along the Authorization header when it attempts to follow redirects on GET requests.  It needs to either provide an option to let users choose whether they want to automatically follow redirects or not (so I can then handle this in my own tasks) or it needs to ensure all headers are also passed along to the new URL as well (especially the authorization one).

Thank you very much for the comment! Would you be able to add that as a feature request please?

Topic is closed for comments