# [✓] Include "Authorization: Bearer ..." in a URL execute?

Posted 1 month ago
254 Views
|
4 Replies
|
3 Total Likes
|
 I am trying to access the Asana api. In order to do that I need to send http requests of the formhttps://api end point "Authorization: Bearer 0/123456789abcdef"I have tried setting Authetication -> <|"Authorization" -> Bearer... |> but that just brings up the asana sign in box. I also tried "Headers" -> "Authorization: Bearer..." |> but that throws the errorHTTPRequest::nvldheaders: -- Message text not found -- (Join[{user-agent->Wolfram HTTPClient 12.},Authorization: Bearer ...What is the correct way to include the Authorization header request in the message?
4 Replies
Sort By:
Posted 1 month ago
 Andrew,HTTP headers have to be passed as a list. Try this HTTPRequest[API_ENDPOINT_URL, <|"Headers" = {"Authorization: Bearer ACCESS_TOKEN"}|>] 
Posted 1 month ago
 Thanks for your suggestion, sadly I am still doing something wrong.This curl command works correctly curl -H "Authorization: Bearer 0/123456789abcdef" https://app.asana.com/api/1.0/users/meI am trying to reproduce that in WL. My current attempt is: header = <|"Headers" -> {"Authorization: Bearer 0/123456789abcdef"}|> URLExecute["https://app.asana.com/api/1.0/users/me", header]Can you see anything wrong with my code, and also is there a way to get Mathematica to show me exactly what it is sending to Asana?
 Andrew,The format for a curl command of curl -H "Authorization: Bearer 0/123456789abcdef"should be HTTPRequest[ "url goes here", <| Method -> "POST", "Headers" -> {"Authorization" -> "Bearer 0/123456789abcdef"}, "Body" -> {"username" -> "myusername", "password" -> "mypwd"} |> ]; This assumes that there is a need for a username and pwd, You may not need a body if you don't need the login.I hope this helps.Regards,Neil