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,

Tags:

Best Answer

  • Brian_Richardson
    Brian_Richardson Overachievers Alumni
    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

    BRIAN RICHARDSON | PMO TOOLS AND RESOURCES | HE|HIM

    SEATTLE WA, USA

    IRON MOUNTAIN

Answers

  • Kelly Moore
    Kelly Moore ✭✭✭✭✭✭

    Hello @lschek1

    To confirm, did you set up a profile for API calls as part of the API call configuration?

    https://help.smartsheet.com/articles/2482056-http-call-utility-function

    Kelly

  • lschek1
    lschek1 ✭✭
    edited 08/15/24

    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.

  • Kelly Moore
    Kelly Moore ✭✭✭✭✭✭
    edited 08/15/24

    @lschek1

    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. 😊

  • lschek1
    lschek1 ✭✭

    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

  • Brian_Richardson
    Brian_Richardson Overachievers Alumni
    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

    BRIAN RICHARDSON | PMO TOOLS AND RESOURCES | HE|HIM

    SEATTLE WA, USA

    IRON MOUNTAIN

  • lschek1
    lschek1 ✭✭

    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 👍️

  • Brian_Richardson
    Brian_Richardson Overachievers Alumni

    Sweet!!!! Glad you got it working!

    BRIAN RICHARDSON | PMO TOOLS AND RESOURCES | HE|HIM

    SEATTLE WA, USA

    IRON MOUNTAIN