anaplan api 401 Not Authorized using Postman

Highlighted
Contributor

anaplan api 401 Not Authorized using Postman

Using Postman: 

I can use Post and get an authorization token, but when I create the Get with Authorization = AnaplanAuthToken <token from Post>

Content-type=application/json

 

Basic Authentication

and workspace ID and Model Id in URL

https://api.anaplan.com/2/0/workspaces/<workspace id>/models/<model id>

 

I get:

{
"status": {
"code": 401,
"message": "Not Authorized."
}
}

 

Any ideas?

12 REPLIES 12
Highlighted
Community Boss

Re: anaplan api 401 Not Authorized using Postman

Hi @stephen.hoffer,

 

The endpoint you used isn't valid for the 2.0 API, fetching model data is now under https://api.anaplan.com/2/0/users/<workspaceId>/models/<modelId>


For further details, please check our 2.0 API guide.

 

Regards



Jesse Wilson
Solution Architect - Data Integrations
Singapore
Highlighted
Contributor

Re: anaplan api 401 Not Authorized using Postman

I just retooled the URL as per your post and the same result.

 

Highlighted
Community Boss

Re: anaplan api 401 Not Authorized using Postman

Hi @stephen.hoffer,

 

Apologies for the mixup on my part, after /users/ it should be your user ID, not workspace. You can obtain this by sending a GET request to https://api.anaplan.com/2/0/users/me

 

Once you have your ID, the URL for model details is

 

https://api.anaplan.com/2/0/users/<user ID>/models/<model ID>

 

Regards



Jesse Wilson
Solution Architect - Data Integrations
Singapore
Highlighted
Contributor

Re: anaplan api 401 Not Authorized using Postman

Interestingly enough, I still cannot get anything my code 401.

 

I can still Post https://auth.anaplan.com/token/authenticate with password and Basic Authentication and get SUCCESS.

But any get still gives 401.

 

I have admin to Anaplan proper and can get into any of my models, so that is absolutely not an issue.

 

It seems odd that I can authenticate via Post and get the Token, but cannot get beyond that point.

 

 

 

 

Highlighted
Occasional Contributor

Re: anaplan api 401 Not Authorized using Postman

Posting a GET to https://api.anaplan.com/2/0/workspaces/{ID}/models/{ID}/exports

is working fine for me. I'll try it without the /exports later if I get time.

 

For a GET your headers should be

  • Accept = application/json
  • Authorization AnaplanAuthToken {token}

There should only be a Content-Type header on POST – not sure if that's making a difference.

I take it you're getting a fresh token often enough too? Though I think the message is specific about expired tokens.

Highlighted
Community Boss

Re: anaplan api 401 Not Authorized using Postman

Could you share a screenshot of your request, including the full Authentication header, to help troubleshoot? 



Jesse Wilson
Solution Architect - Data Integrations
Singapore
Highlighted
Contributor

Re: anaplan api 401 Not Authorized using Postman

The Auth Token was copied from the authentication POST and the Get was run right afterward

 

GET

https://api.anaplan.com/2/0/workspaces/8a81b09c652b03b101654519bfe258d4/models/5D597B7A61B94E9EBB127... RT6nJJlsp7Ob421uHl0GHg==.qMbCcIlo5Sf72aVROHBDCKMkmvDg222STZdl4/o7Lm7OFjlvNUqrYwGvVZZFtmGr+FOZmEJ5Tt9Hno2gHaEN7Hnrn420EWz8+kDOnBKgPLQ5Nk937YqujcP/+Yr/RifwvNfwF6EKV7CkaQwZoaSa0ohDpdXfPcz9nbbJEzce3Q/kpAGyHjE1E6AzU1X0kJ7yzmDUcxpfm2qStCwUqiARoAo3oKGDAA+ikPLFN5KiFQdsFluQGy3hk+Jj93DXl7gBdOHUNvkZhqEFhZDxoY9m+he25aWTJF1JCZLXlgENTdPb5ZQ6AWBVZhGk7k68av5ydM7l86lF4xZVeDrsVBfViI6gwzFSDfrB0+TeWMzRCRT7iJXpCZTeQMyLp4FkqgahcAtG8Z+dimv6gfsGDwvow1NBhfdzNisUHcGjQzaG8Pl1oT8bA/pxEF5+m76Cl3018Wbuj3eU4gOvehSKe8PryA==.iimhxvndXKdDTITPqB5FyPGo9NjTnS3LqDKn/m4GYnw=&content-type=application/json

Highlighted
Contributor

Re: anaplan api 401 Not Authorized using Postman

 
Highlighted
Occasional Contributor

Re: anaplan api 401 Not Authorized using Postman

Looks like you're passing the token as a parameter instead of a header.

 

I've attached a screenshot of mine for example.