How to test CRUD requests through REST API
Table of сontents
Prerequisites
Register on InCountry Portal at https://portal.incountry.com/login.
Create a new REST API integration.
Copy details of the REST API integration, as follows:
Environment ID
Client ID
Client Secret
REST API address
Load the request collection into Postman.
Creating an access token
To find out the appropriate OAuth server (authorization endpoint) for you country, please check this page.
Within the Postman collection, locate and select the Authorization request.
Enter the address of the authorization endpoint:
EMEA:
https://auth-emea.incountry.com/oauth2/token
APAC:
https://auth-apac.incountry.com/oauth2/token
In the Username box, enter the Client ID you received on InCountry Portal.
In the Password box, enter the Client Secret you received on InCountry Portal.
Switch to the Body tab.
Define the body parameters, as follows:
grant_type
- enterclient_credentials
. This value is already specified in the collection you loaded.audience
- enter the address of the REST API endpoint that you received on InCountry Portal. Add the address of the point-of-presence in addition to the REST API endpoint. For example, the address of the REST API endpoint you received ishttps://id-restapi-mt-01.api.incountry.io
. Within this URL, remove the-restapi
part, so the point-of-presence will behttps://id-mt-01.api.incountry.io
. You need to add these two addresses separated with a space, as follows:https://id-restapi-mt-01.api.incountry.io https://id-mt-01.api.incountry.io
. Please consider that for each country, the REST API endpoint address will vary, as well as the point-of-presence.scope
- enter the environment ID you received on InCountry Portal.
WarningPlease consider that the authorization token expires every 300 seconds. You need to re-generate a new token regularly.
Click Send. Upon successful execution of the request, you will get the authorization token in the response.
Creating a new record
Within the Postman collection, locate and select the Create a record request.
Enter the address of the REST API endpoint instead of the
{{DEMO_URL}}
snippet.Switch to the Body tab, then select raw.
Enter the body request with the record data, as follows. For the country parameter, enter the country code. For example, your REST API endpoint is attributed to Sweden, use
se
.{
"country": "id",
"key": "eternals",
"record_key": "eternals",
"body": "{ firstName: 'Marvel', lastName: 'Comics'}",
"key1": "eternals"
}Switch to the Authorization tab.
In the Type box, select
Bearer Token
.In the Token box, enter the authorization token you get in the Authorization request.
Click Send. Upon successful execution of the request, a new record will be created on the InCountry platform.
Creating multiple records
Within the Postman collection, locate and select the Create batch request.
Enter the address of the REST API endpoint instead of the
{{DEMO_URL}}
snippet.Switch to the Body tab, then select raw.
Enter the body request with the record data, as follows. For the country parameter, enter the country code. For example, your REST API endpoint is attributed to Sweden, use
se
.{
"country": "id",
"records": [
{
"record_key": "superman",
"body": "{firstName: 'Tony', lastName: 'Stark'}",
"range_key1": 1001,
"key1": "'Tony'"
},
{
"record_key": "batman",
"body": "{firstName: 'Gemma', lastName: 'Chan'}",
"range_key1": 1002,
"key1": "'Gemma'"
}
]
}Switch to the Authorization tab.
In the Type box, select
Bearer Token
.In the Token box, enter the authorization token you get in the Authorization request.
Click Send. Upon successful execution of the request, multiple records will be created on the InCountry platform.
Finding a specific record
Within the Postman collection, locate and select the Find records request.
Enter the address of the REST API endpoint instead of the
{{DEMO_URL}}
snippet.Switch to the Body tab, then select raw.
Enter the body request with the record data, as follows. For the country parameter, enter the country code. For example, your REST API endpoint is attributed to Sweden, use
se
.{
"country": "id",
"filter": {
"key1": "'Tony'"
},
"options": {
"limit": 10,
"offset": 0
}
}Switch to the Authorization tab.
In the Type box, select
Bearer Token
.In the Token box, enter the authorization token you get in the Authorization request.
Click Send. Upon successful execution of the request, you will see information about the created record on the InCountry platform.
Deleting a specific record
Within the Postman collection, locate and select the Delete a record request.
Enter the address of the REST API endpoint instead of the
{{DEMO_URL}}
snippet.Replace the
ae
snippet with the actual country code.Replace the
:recordKey
snippet with the record key you created on the InCountry platform.Switch to the Authorization tab.
In the Type box, select
Bearer Token
.In the Token box, enter the authorization token you get in the Authorization request.
Click Send. Upon successful execution of the request, the created record will be removed on the InCountry platform.
Attaching a file
Within the Postman collection, locate and select the Attach file request.
Enter the address of the REST API endpoint instead of the
{{DEMO_URL}}
snippet.Replace the
ae
snippet with the actual country code.Replace the
:recordKey
snippet with the key of the record which an uploaded file will be mapped to on the InCountry platform.Switch to the Body tab, then select form-data.
For the file parameter, click Select Files and select the attachment you want to upload.
Switch to the Authorization tab.
In the Type box, select
Bearer Token
.In the Token box, enter the authorization token you get in the Authorization request.
Click Send. Upon successful execution of the request, the file will be attached to the record on the InCountry platform. Within the response, you will get the identifier of the attached file.
Downloading an attached file
Within the Postman collection, locate and select the Attach file request.
Enter the address of the REST API endpoint instead of the
{{DEMO_URL}}
snippet.Replace the
ae
snippet with the actual country code.Replace the
:recordKey
snippet with the key of the record which an uploaded file is mapped to on the InCountry platform.Replace the
:fileId
snippet with the file identifier you received when attached a file.Switch to the Authorization tab.
In the Type box, select
Bearer Token
.In the Token box, enter the authorization token you get in the Authorization request.
Click Send. Upon successful execution of the request, the file will be downloaded from the InCountry platform.
Deleting an attached file
Within the Postman collection, locate and select the Attach file request.
Enter the address of the REST API endpoint instead of the
{{DEMO_URL}}
snippet.Replace the
ae
snippet with the actual country code.Replace the
:key
snippet with the key of the record which an uploaded file is mapped to on the InCountry platform.Replace the
:fileId
snippet with the file identifier you received when attached a file.Switch to the Authorization tab.
In the Type box, select
Bearer Token
.In the Token box, enter the authorization token you get in the Authorization request.
Click Send. Upon successful execution of the request, the file will be deleted from the InCountry platform.