api v2 - POSTMAN examples

Highlighted
Certified Master Anaplanner

api v2 - POSTMAN examples

I am sorry for not posting these POSTMAN examples sooner. You can download the attached file and import them into your Postman. 

There are over 30 examples of different ways to hit the API. and this is for those users who are not using cURL. 

 

These range from Exports, Imports, uploading data, and reviewing dump files.  

I hope these are beneficial.

 

NOTE: you may have to update the file extension from .txt to .json. Anaplan community does not all .josn

8 REPLIES 8
Highlighted
Master Anaplanner/Community Boss

Re: api v2 - POSTMAN examples

Thanks Jason for both V1 and V2 examples.

Very, very helpful.

 

 


Jared Dolich
Highlighted
Community Boss

Re: api v2 - POSTMAN examples

I'm curious about this one:

 

"https://api.anaplan.com/2/0/workspaces"

 

I tried it recently and confirm it with R&D: this endpoint doesn't exist in 2.0

Did you manage to make it work or is it a mistake ? 


Nathan Rudman, Anaplan Model Builder
Highlighted
Certified Master Anaplanner

Re: api v2 - POSTMAN examples

I actually had a conversation with my rep today. the endpoint Workspace does return a result, however what I was told is that the result may not reliable. 

Also the endpoint of models that works in version 1/3 does not work at all in version 2. 

 

it was nice to be able to see all those values without have to open up the model.  Not sure why it is not current available. 

Highlighted
Contributor

Re: api v2 - POSTMAN examples

Hello Jason,

 

I'm just starting with certificates, and am a bit struggling there.

I already collected my certificate from my CA and imported it in Anaplan Administration.

 

So I have the following files:

- userAnaplan.cnf: the config file that helped me generate my private Key file and my CSR

- userAnaplan.csr: the CSR generated from the CNF file

- userAnaplan.key: the private key file generated from the CNF file

- userAnaplan.p7b: the certificate issued by my CA based on the CSR

- userAnaplan.pem: the certificate extracted from the P7B file

 

And now I want to do a first login to Anaplan API, using the auth.anaplan.com/token/authenticate URI.

I already managed to get a token using a username and password, but struggle with the certificate.

 

I downloaded your Postman sample, but could you detail a little more please how do you generate the data for the different fields:

{{ca cert value}}

encodedData

encodedSignedData

Which command lines or tools do you use to generate the base64 versions of the data using the files above?

 

Thanks a lot,

FX

Highlighted
Master Anaplanner/Community Boss

Re: api v2 - POSTMAN examples

Hi FX,

Check my comment here for how to get the encoded data and signed data headers
https://community.anaplan.com/t5/Anaplan-Platform/Using-CA-Certificate-to-execute-Anaplan-REST-API-2...
Francis has posted the solution in C# in the same post

You can also achieve the same result in Python by following this
https://community.anaplan.com/t5/Best-Practices/Anaplan-API-2-0-Python-Library/ta-p/38139
Although this does not work on Windows...

Let me know if you need more help

Regards,
Anirudh
Highlighted
Certified Master Anaplanner

Re: api v2 - POSTMAN examples

 I also have a Java solution as well. 

Highlighted
Contributor

Re: api v2 - POSTMAN examples

Hello,

 

Based on your code samples, I tried to create a Postman pre-request script that allows me to generate the authentication header.

However, Anaplan keeps sending me back a 401 (FAILURE_BAD_CREDENTIAL).

 

Here is my request:

 

POST /token/authenticate HTTP/1.1
Host: auth.anaplan.com
Authorization: CACertificate {{anaplan_certificate}}
Content-Type: application/json

{
    "encodedData": {{anaplan_encodedString}},
    "encodedSignedData": {{anaplan_signedString}}
}

 

And here is my pre-request script:

 

function randomString(length, chars) {
    var result = '';
    for (var i = length; i > 0; --i) result += chars[Math.floor(Math.random() * chars.length)];
    return result;
}

var randomString = randomString(150, '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
var signedString = CryptoJS.HmacSHA512(randomString, pm.environment.get("anaplan_secretkey"));

pm.environment.set("anaplan_encodedString", btoa(randomString));
pm.environment.set("anaplan_signedString", btoa(signedString));

 

 

The Postman environment variable "anaplan_certificate" contains the content of my certificate file, without "-----BEGIN CERTIFICATE-----" and "-----END CERTIFICATE-----" and where I removed all CR and LF characters. It's basically just a very long string looking like "MIIFHzCCBAegAwIBA.............EWmQjqsbcj2zY09pew==".

The Postman environment variable "anaplan_secretkey" contains the content of my certificate file, without "-----BEGIN PRIVATE KEY-----" and "-----END PRIVATE KEY-----" and where I removed all CR and LF characters. It's basically just a very long string looking like "MIIEvQIBADANBgk.............RtgkrHJ+SKp/EFH2PhBx1xjE=".

 

The certificate is correctly imported on my Anaplan administration console too.

2020-09-22 11_32_24 - Base.png

 

 

 

Any idea on what I am doing wrong?

 

Thanks for your help,

FX

Highlighted
Contributor

Re: api v2 - POSTMAN examples

Hello @Jason_C  and @anirudh 

By any chance do you have any clue on what I should do so the Postman script to login with certificate that I posted just before would work?

I suspect CryptoJS.HmacSHA512 to give me a wrong value, but I'm really not sure.

Thanks a lot,

FX