Postman
Introduction
To make integrating with the Sharespine API as easy as possible you can create a Postman collection that you can populate with your own application credentials and environment variables. You create the collection from the most recent API definition so it will always be up to date.
Create collection
Creating the collection this way involves a few steps but bare with us, it will be worth it in the end.
- Get the swagger file from here and save it.
- Open Postman and click on File - Import
- Select the file you saved
- TIP: Click
Show advanced setting
and enable the settingDisable optional parameters
to get more clean requests - A new collection is now created
- Click Collections, select the new collection and click
...
to edit the collection - Choose the Authorization tab and set type to
Basic Auth
- Enter
{{username}}
and{{password}}
in the Username and Password fields. These are variables that will be used for all endpoints in this collection - Go to the tab
Pre-request Scripts
and paste the following code as is. This makes sure that the required authorization headers are set for each request.
pm.request.headers.add(
{
key: 'X-Tenant',
value: pm.environment.get("tenant")
}
)
pm.request.headers.add(
{
key: 'X-ConnectionId',
value: pm.environment.get("connectionId")
}
)
Note
The settings for authorization and pre-request scripts should be done on the collection to apply the changes to all calls in the collection.
Create environment
Now we need to create an environment to hold the required variables. Create a new environment for each project or development environment to get a truly flexible setup.
- Click Environments in the left hand menu
- Click the plus (+) sign to create a new environment
- Create the following variables and fill them with the information you have received related to your project.
- tenant
- username
- password
- baseUrl
- connectionId
- Make sure that the correct environment is chosen in the right hand corner before the first request is sent. If no environment is selected
No environment
is shown. - You are now ready to test your first API call!