Problem when authenticating token in API Call. Smartsheet Bridge
When I run a Make API Call I get an 401 error, Invalid Token.
I have configured the HTTP request body as per specifications from the website API documentation; it's a POST request, and the actual token has been put both within commas and without it.
I believe the token is not the problem because I tested the code in IDEs and it works fine, so I would like to know what's missing for me to configure.
Best regards,
Best Answer
-
I'm sorry I didn't see this post for so long. I can think of a couple of items to check
- If you are doing a POST, you have to specify the header Content-Type: application/json . Postman automatically applies this header when you have a body, but Smartsheet does not.
- If you're posting to the Smartsheet API, the token needs to be in an Authentication header like this; Authentication: Bearer token_id. It sounds like you're posting to some other API, but you still might try putting the token in as a header with the same format (include the Bearer string in front of the token ID as part of the value)
- I would recommend adjusting your Call API setup to end the URL string at /integrations, and then in the Make Call step in your workflow identify the endpoint as /add_tracking_number. Not positive that makes a difference but Make Call is designed to have an endpoint defined in the step and may be having parsing issues with any parameters that you have as part of the call
Answers
-
Hello @lschek1
To confirm, did you set up a profile for API calls as part of the API call configuration?
Kelly
-
Hello Kelly, I did set up the API configuration, I put the base URL (for this case, it is to add a tracking to a platform), but I'm not sure if I should add more info, perhaps? I tried adding the token in secret headers, but I still get an invalid token error.
As for the Call API utility, it is set in POST, there is no Endpoint or Form Parameters included.
This specific website says to specify the URL and push a JSON body to add the information I need. For example, this is how I would set it up successfully.
-
I'm not certain this is a profile problem - all I know is I get non-descript error codes from profile problems. Here is my profile
Here is the rest of the set-up for one of my POST calls. Most of the problems I've had are caused by my endpoint text.
My HTTP request body parameters follow the relevant API document syntax for this particular routine
If this doesn't help, mark the answer as unanswered or whatever the choice is to that effect. Then someone else will step in with better solutions
Kelly
PS Please @mention if you reply to help filter your email from others in my inbox. 😊
-
Unfortunately I'm still unable to get this POST request to work. I tried changing parameters but still wasn't successful. I think it has to do with the own API docs and the http body.
At least I managed to make a GET request. or this case, I only needed to add the form parameters and the URL body.
I am grateful for your help @Kelly Moore
-
I'm sorry I didn't see this post for so long. I can think of a couple of items to check
- If you are doing a POST, you have to specify the header Content-Type: application/json . Postman automatically applies this header when you have a body, but Smartsheet does not.
- If you're posting to the Smartsheet API, the token needs to be in an Authentication header like this; Authentication: Bearer token_id. It sounds like you're posting to some other API, but you still might try putting the token in as a header with the same format (include the Bearer string in front of the token ID as part of the value)
- I would recommend adjusting your Call API setup to end the URL string at /integrations, and then in the Make Call step in your workflow identify the endpoint as /add_tracking_number. Not positive that makes a difference but Make Call is designed to have an endpoint defined in the step and may be having parsing issues with any parameters that you have as part of the call
-
Hello Brian. Awesome, your suggestions worked fine, now I'm able to run this process within Smartsheet without needing to host this particular POST request in another platform hahaa
So I followed all of your suggestions, but in order to drill down to exactly what solution was the one that made this workflow work was including the header Content-Type: application/json and adding /add_tracking_number as the endpoint, modifying the API Call to end at /integrations.
Thank you so much for your help 👍️
-
Sweet!!!! Glad you got it working!
-
Hi @Brian_Richardson, sorry for the inconvenience in this thread again, the workflow above is not working for me when I add the http body values using Data Reference for previous steps. The other day I implemented it only with hard-coded values and it worked, even now it works if I put the values directly.
When I revisit this workflow with the previous configurations above, it returns an invalid token error, although the token should be fine as it hasn't expired yet. The steps from Compose Text in each State is called in the Call API step. I also tried the Authorization Bearer Token suggestion but it still returns an error.
I validated each State and they return the correct value, also, they were set accordingly in Call API step within the http body request in its corresponding key-value, but it looks like those Data References are not recognized when executing the Post request.
-
You have to put quotes around the references in the body.
So like {“token”:”{{reference}}”}
-
That did the job. Thank you so much for everything! Happy weekend 👍️
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.8K Get Help
- 434 Global Discussions
- 136 Industry Talk
- 470 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 65 Community Job Board
- 485 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives