"401 Unauthorized" when sending HTTP request through javascript on POSTMAN (but not with a simple HTTP request) | The place for Zendesk users to come together and share
Skip to main content
July 10, 2025
Question

"401 Unauthorized" when sending HTTP request through javascript on POSTMAN (but not with a simple HTTP request)

  • July 10, 2025
  • 1 reply
  • 40 views

for a url ${baseUrl}/users/${user.id}.json where baseUrl = ‘https://{subdomain}.zendesk.com/api/v1

I was able to run PUT request on Postman to edit custom field in the data with ease.

The authentication method I used was 

[Basic Auth]

username: {email}/token

password: API token I generated

 

And yet, for a bulk update over the json data, (user list) using either of the script I am getting 401 error

1. pm.sendRequest({

    url: `${baseUrl}/users.json`,

    method: 'GET',

    header: {

        'Content-Type': 'application/json',

        'Authorization': pm.environment.get('auth')

    }

2.  ----the rest same----

   header: {

        'Content-Type': 'application/json',

        'Authorization': pm.request.headers.get('Authorization')

    }

Does anyone have advise? Thank you

1 reply

Employee
July 16, 2025
Hello,
 
Can you double-check the value you're providing to the Authorization header definition from your snippet?  Verify that it is a base-64 encoded value of the {email_address}/token:{api_token} string you intend to supply for auth.