How do I construct a curl (assuming that’s what I need) request for =importJSON (popular Google Sheets script)?
I’m using a Google script that allows me to import JSON data. I’m now at the point where I’m trying to run it, and I’m getting an authorization error.
I used the help in Asana, but I’m not sure how to set up the request.
Thanks!
Chris
PS: Here’s the version of importJSON I’m using: GitHub - bradjasper/ImportJSON: Import JSON into Google Sheets, this library adds various ImportJSON functions to your spreadsheet
Hey @Chris_Stadler, sorry you’re having an issue with this. I’m not familiar with all of the request options with Google Sheets. The Asana API has three types of auth: OAuth, Personal Access Tokens, and cookie auth. You would need to use one of these to auth your request from Sheets. For example, you could put a PAT in the header of your request (assuming that’s possible). Good luck!
1 Like
Thanks, Jeff.
So if I understand it correctly, the PAT can’t sit in the URL/CURL so I can have a one-line request?
Thanks!
Chris
No, it can:
-H "Authorization: Bearer 0/a7f89e98g007e0s07da763a"
(note: not a real Auth value)
Just include the above in your CURL string where you replace the 0/a7f89e98g007e0s07da763a
part with your PAT.
1 Like
Thanks, Phil. I guess that’s my confusion (and probably shows my inexperience). I saw that in the documentation, but I’m not sure how that looks in a curl. I’ve done a bunch of searching, but I’m probably asking the question wrong.
Or maybe it doesn’t go into the actual line?
No worries, Chris!
Here’s an example of a CURL request:
curl "https://app.asana.com/api/1.0/users/me" -H "Authorization: Bearer 1/1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxd"
2 Likes
Thanks for your help, Phil. @Chris_Stadler as you can see in the example, the PAT goes in the header of the request (that’s what the “-H” stands for in the CURL request). The PAT cannot go in the URL.
2 Likes