Help with auth token in header

Dear All, I’m having trouble getting a response back from my Zoho API. I have successfully got my access-token from Zoho via an OAuth request, but when I make my GET request it returns as per the screenshot. This is minutes after refreshing my access token. I have checked my environment settings and the refreshed access code is updated fine. Zoho API documentation refers to ‘zoho-oauthtoken {{access-token}}’ and support have confirmed that should be in the ‘header’ of my request. But something is not right with my settings. Any ideas…?

Hey @martin1

Welcome to the community! :trophy:

Do you have a pre-request script at the folder or collection level doing something else?

This should show you how to check that:

https://learning.postman.com/docs/postman/scripts/pre-request-scripts/#re-using-pre-request-scripts

Thx Danny. But no, that tab is empty, so too are all the others, except Headers. Authorization is set as ‘inherit auth from parent’. Can you suggest to a newbie the way I’d check outside of Postman? What is the script I’d run and in what app? Or can you see from their Documentation https://www.zoho.com/crm/developer/docs/api/get-records.html what Postman settings I should have? When I get my access-token it calls it type ‘Bearer’ should that go anywhere?

In the docs, it’s Zoho-oauthtoken with an upper case Z.

How are you getting the access token? Can you copy just the raw token value into the header to ensure that it works before add it to a variable.

The Postman console is another place that you can check what’s being sent, open it via the 3rd icon on the left side of the bottom bar.

You mentioned is add Bearer, you might find that it’s sending zoho-oauthtoke Bearer <token value>

Thx again. I’ve tried all sortys of variations, no dice. Any tips on how to call it via js script in a html file? Where can I find that script template or what would I google do you think…?

I don’t really know what you’re trying/now seeing so it’s difficult for me to know where you’re currently at so any updates with images of what you can see would help :smiley:

  • How are you getting the Auth Token? Is that with the helper in the Auth tab?

  • Did the raw value, added straight into the header not work? eg Zoho-oauthtoken <token value>

  • Where hovering the cursor over the variable you have in place, doesn’t the value say Bearer xxxx or xxxx

  • In the screenshot, you have something extra in the params tab but not in the URL so you might want to remove that.

  • Are you sure that token is valid for that domain, that’s a variable so I don’t know for sure.

These are all guesses as I don’t know what you have in front of you :smiley:

I just tried it using js and it still returned an error. I have gone back to Zoho support. Thx.

This was my script… if you can spot any syntax errors?

//My first Zoho API test

var ourRequest = new XMLHttpRequest();
ourRequest.open('GET', 'https://www.zohoapis.eu/crm/v2/Products', {'Authorization': 'Zoho-oauthtoken 1000.47f9a666a3baa23055xxxxxxxxxxxx.051e9297c478cd2e2fbxxxxxxxxxxxxxxx'});
ourRequest.onload = function() {
var ourData = JSON.parse(ourRequest.responseText);
console.log(ourData[0]);
};
ourRequest.send();

Is there a reason that you’re not just making that call in the app? Are you using that script elsewhere?

How are you setting the variable that you’re using in the first image you posted.

You could either have that as a normal request and save the token from the response as a variable or in a pre-request script with pm.sendRequest().