Postman API Calls

Happy Friday all!
I am not a developer and never claimed to be, but am the admin for IDNow and have been using Postman for about four years now. I keep having issues with the new API calls and I cannot figure out what I’m doing wrong or what I don’t have configured correctly. I followed the API doc about making your first API call and setup my PAT in IDNow. I also setup my new environment variables within Postman. However, I keep getting a 401 error saying that the “JWT is required”. After talking with an ex-SailPoint engineer, he had me remove the access-token and access-expiry values that were being populated during a successful call. That day, I made several successful API calls. Now… It’s a new day and clearing those values out is not working and I need to load a new transform prior to testing next week. Can anyone please tell me WTH am I doing wrong here?!

Thanks!
Nate

Hello @npilley,

Welcome to the Sailpoint Developer Community!

If you are using the latest official postman collections you’ll want to make sure the following information is in place.

Check that the collection environment variables are set correctly. Click on the collection name IdentityNow V3 APIs that you have forked and verify that the domain and baseUrl are set on the Variables Tab.

Next, verify that you have the Authorization tab using the environment variable accessToken for authenticating to our APIs.

On the Pre-request Script tab verify that you have the latest script for retrieving and storing your accessToken.

const domain = pm.environment.get('domain') ? pm.environment.get('domain') : pm.collectionVariables.get('domain')
const tokenUrl = 'https://' + pm.environment.get('tenant') + '.api.' + domain + '.com/oauth/token';
const clientId = pm.environment.get('clientId');
const clientSecret = pm.environment.get('clientSecret');

const getTokenRequest = {
    method: 'POST',
    url: tokenUrl,
    body: {
        mode: 'formdata',
        formdata: [{
                key: 'grant_type',
                value: 'client_credentials'
            },
            {
                key: 'client_id',
                value: clientId
            },
            {
                key: 'client_secret',
                value: clientSecret
            }
        ]
    }
};


var moment = require('moment');
if (!pm.environment.has('tokenExpTime')) {
    pm.environment.set('tokenExpTime', moment());
}


if (moment(pm.environment.get('tokenExpTime')) <= moment()) {
    var time = moment();
    time.add(12, 'hours');
    pm.environment.set('tokenExpTime', time);
    pm.sendRequest(getTokenRequest, (err, response) => {
        const jsonResponse = response.json();
        const newAccessToken = jsonResponse.access_token;
        pm.environment.set('accessToken', newAccessToken);
    });

}

Finally, you will need an environment like the one you have included in your post with only the following values.

Environment Variable Required Description
tenant * This is your IdentityNow tenant, typically your company’s name.
clientId * This is the client ID for the API client or personal access token.
clientSecret * This is the client secret for the API client or personal access token.
domain This field is optional and is only needed for a select few who may have a domain in their API URL that differs from “identitynow”.

Please let us know if you still experience issues!

1 Like