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?
Answers
-
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
0 -
I just retooled the URL as per your post and the same result.
0 -
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
0 -
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.
0 -
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.
1 -
Could you share a screenshot of your request, including the full Authentication header, to help troubleshoot?
0 -
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/5D597B7A61B94E9EBB1270B6A3DB02BB/exports?Authorization=AnaplanAuthToken RT6nJJlsp7Ob421uHl0GHg==.qMbCcIlo5Sf72aVROHBDCKMkmvDg222STZdl4/o7Lm7OFjlvNUqrYwGvVZZFtmGr+FOZmEJ5Tt9Hno2gHaEN7Hnrn420EWz8+kDOnBKgPLQ5Nk937YqujcP/+Yr/RifwvNfwF6EKV7CkaQwZoaSa0ohDpdXfPcz9nbbJEzce3Q/kpAGyHjE1E6AzU1X0kJ7yzmDUcxpfm2qStCwUqiARoAo3oKGDAA+ikPLFN5KiFQdsFluQGy3hk+Jj93DXl7gBdOHUNvkZhqEFhZDxoY9m+he25aWTJF1JCZLXlgENTdPb5ZQ6AWBVZhGk7k68av5ydM7l86lF4xZVeDrsVBfViI6gwzFSDfrB0+TeWMzRCRT7iJXpCZTeQMyLp4FkqgahcAtG8Z+dimv6gfsGDwvow1NBhfdzNisUHcGjQzaG8Pl1oT8bA/pxEF5+m76Cl3018Wbuj3eU4gOvehSKe8PryA==.iimhxvndXKdDTITPqB5FyPGo9NjTnS3LqDKn/m4GYnw=&content-type=application/json
0 -
Looks like you're passing the token as a parameter instead of a header.
I've attached a screenshot of mine for example.
0 -
@stephen.hoffer, you put all of the content in the Parameters tab rather than Headers, so our API server can't see your authentication. I do see you have one header defined, I suspect this is an Authentication header - you have go back to the Authorization tab, and change type to "No Auth", or whatever values you have there will override any Authentication header you define manually.
The request should look like this:
1 -
I accept the last two as answers because together they filled in the pieces
0 -
Just a post-mortem:
It turns out that the anaplan URLs needed for the API to work were not on the whitelist...or got automatically put on the blacklist which caused on again then off again functionality.
Once this was addressed there were no more issues with running an export action via the API.0 -
@stephen.hoffer I am experiencing a similar issue. Token gets generated but then I receive 401 for any other API. What do you mean with whitelist/blacklist? Is this something that needs to be setup in Anaplan? Thanks
0