Using Postman to test ODATA API in OnPrem system
SAP Logon inbuilt gateway client is an out-of-box tool to test OData API, but if you want to be more efficient, a better tool is needed.
According to official introduction, postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster. So how can we use postman test our OData API faster and easier.
First of all, you need authorization to access the API which is not needed in gateway client. Gateway client will directly use your developer user to access the API, this is obviously not appropriate especially when you want to do some authorization test. Let’s start with creating a role.
- Create a role named ZPOSTMAN
- Add Authorization Default in Menu tab
- Select authorization type based on your service
- Find you API service
- Then move to Authorizations tab
- Add all the authorization you need to access your API, these authorization objects can be various according your API.
- Generate and save your role.
- After we have the role, we need to create an user
- Change User type to B System and provide a password in Logon Data tab.
- The most important thing is to assign your role created before to this user
Then save your user. Now we can move to Postman.
- Create a new collection and add a new request in.
- You can copy and paste your URL from gateway client.
- In Auth tab, select type Basic Auth and enter your created user and password.
Then we are good to go!
Note that you may need to explicit assign client in your URL if you get a 401 unauthorized error when sending request. Append “?$sap-client=001” after your URL.
Leave you comments below if you have any questions, and you can also refer to this blog: S/4HANA Cloud API Consumption 101 – Using Postman to Test | SAP Blogs for cloud usage.