Skip to main content

How to test CRUD requests through REST API

Table of сontents

Prerequisites

  1. Register on InCountry Portal at https://portal.incountry.com/login.

  2. Create a new REST API integration.

  3. Copy details of the REST API integration, as follows:

    1. Environment ID

    2. Client ID

    3. Client Secret

    4. REST API address

      REST API integration

  4. Download the Postman collection.

  5. Load the request collection into Postman.

Creating an access token

tip

To find out the appropriate OAuth server (authorization endpoint) for you country, please check this page.

  1. Within the Postman collection, locate and select the Authorization request.

  2. Enter the address of the authorization endpoint:

    1. EMEA: https://auth-emea.incountry.com/oauth2/token

    2. APAC: https://auth-apac.incountry.com/oauth2/token

  3. In the Username box, enter the Client ID you received on InCountry Portal.

  4. In the Password box, enter the Client Secret you received on InCountry Portal.

    Authorization request

  5. Switch to the Body tab.

    Body parameters

  6. Define the body parameters, as follows:

    • grant_type - enter client_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 is https://id-restapi-mt-01.api.incountry.io. Within this URL, remove the -restapi part, so the point-of-presence will be https://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.

    Warning

    Please consider that the authorization token expires every 300 seconds. You need to re-generate a new token regularly.

  7. Click Send. Upon successful execution of the request, you will get the authorization token in the response.

Creating a new record

  1. Within the Postman collection, locate and select the Create a record request.

  2. Enter the address of the REST API endpoint instead of the {{DEMO_URL}} snippet.

  3. Switch to the Body tab, then select raw.

    Select raw

  4. 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"
    }
  5. Switch to the Authorization tab.

  6. In the Type box, select Bearer Token.

  7. In the Token box, enter the authorization token you get in the Authorization request.

  8. Click Send. Upon successful execution of the request, a new record will be created on the InCountry platform.

Creating multiple records

  1. Within the Postman collection, locate and select the Create batch request.

  2. Enter the address of the REST API endpoint instead of the {{DEMO_URL}} snippet.

  3. Switch to the Body tab, then select raw.

  4. 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'"
    }
    ]
    }
  5. Switch to the Authorization tab.

  6. In the Type box, select Bearer Token.

  7. In the Token box, enter the authorization token you get in the Authorization request.

  8. Click Send. Upon successful execution of the request, multiple records will be created on the InCountry platform.

Finding a specific record

  1. Within the Postman collection, locate and select the Find records request.

  2. Enter the address of the REST API endpoint instead of the {{DEMO_URL}} snippet.

  3. Switch to the Body tab, then select raw.

  4. 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
    }
    }
  5. Switch to the Authorization tab.

  6. In the Type box, select Bearer Token.

  7. In the Token box, enter the authorization token you get in the Authorization request.

  8. Click Send. Upon successful execution of the request, you will see information about the created record on the InCountry platform.

Deleting a specific record

  1. Within the Postman collection, locate and select the Delete a record request.

  2. Enter the address of the REST API endpoint instead of the {{DEMO_URL}} snippet.

  3. Replace the ae snippet with the actual country code.

  4. Replace the :recordKey snippet with the record key you created on the InCountry platform.

    Replace the record key

  5. Switch to the Authorization tab.

  6. In the Type box, select Bearer Token.

  7. In the Token box, enter the authorization token you get in the Authorization request.

  8. Click Send. Upon successful execution of the request, the created record will be removed on the InCountry platform.

Attaching a file

  1. Within the Postman collection, locate and select the Attach file request.

  2. Enter the address of the REST API endpoint instead of the {{DEMO_URL}} snippet.

  3. Replace the ae snippet with the actual country code.

  4. Replace the :recordKey snippet with the key of the record which an uploaded file will be mapped to on the InCountry platform.

  5. Switch to the Body tab, then select form-data.

    Select form-data

  6. For the file parameter, click Select Files and select the attachment you want to upload.

  7. Switch to the Authorization tab.

  8. In the Type box, select Bearer Token.

  9. In the Token box, enter the authorization token you get in the Authorization request.

  10. 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

  1. Within the Postman collection, locate and select the Attach file request.

  2. Enter the address of the REST API endpoint instead of the {{DEMO_URL}} snippet.

  3. Replace the ae snippet with the actual country code.

  4. Replace the :recordKey snippet with the key of the record which an uploaded file is mapped to on the InCountry platform.

  5. Replace the :fileId snippet with the file identifier you received when attached a file.

    Replace the fileID

  6. Switch to the Authorization tab.

  7. In the Type box, select Bearer Token.

  8. In the Token box, enter the authorization token you get in the Authorization request.

  9. Click Send. Upon successful execution of the request, the file will be downloaded from the InCountry platform.

Deleting an attached file

  1. Within the Postman collection, locate and select the Attach file request.

  2. Enter the address of the REST API endpoint instead of the {{DEMO_URL}} snippet.

  3. Replace the ae snippet with the actual country code.

  4. Replace the :key snippet with the key of the record which an uploaded file is mapped to on the InCountry platform.

  5. Replace the :fileId snippet with the file identifier you received when attached a file.

    Replace the fileID

  6. Switch to the Authorization tab.

  7. In the Type box, select Bearer Token.

  8. In the Token box, enter the authorization token you get in the Authorization request.

  9. Click Send. Upon successful execution of the request, the file will be deleted from the InCountry platform.