No, it’s just a note-to-self.
A lot of customers have been using ServiceAPI, and to great successes. We also have very good documentation here – of which largely thanks to my colleague Mark Hall. But what if you want to play around with ServiceAPI and don’t want to write app/build/run it yourself? The answer is simple: There are many REST Clients can do the job for you, and Postman is usually regarded as the best/most popular one.
But, the documentation are for C# client, it can be quite confusing to use Postman to work with ServiceAPI for the first time (or times). If you are experienced with Postman, great! But if you are not – like me – when you use Postman from time to time and everytime it’s new, then this post can be useful to you. Today I need to do some tests with ServiceAPI, and I had to spend some time figuring out how to use Postman – so I decided it’s better to have all of those noted for future reference.
When you have an up and running ServiceAPI instance, time to fire up Postman and do some RESTful stuffs:
First of all, you need a bearer/access token. To get that, you need to send a POST request to
https://yoursite.com/episerverapi/token , with the body containing
password , like this
Now you have the access token, you need to include it in upcoming requests. No you don’t add a header with
Key = “Bearer”, with the value of the access token. To use it in a GET operation for example, you need to add a header with
Key = “Authentication”, and
Value as “Bearer <Your access token, without the quotes>”, like this
Now if you need to POST/PUT any data, you should put the
Authentication header as above, but with the
Content-Type, and the in Body tab, select “raw” data type (If you choose
JSON(application/json), then Postman will automatically add the
Content-Type header for you. Pretty cool, huh?
And that’s basically everything you need to know to make Postman works for you!