4 min read

Post a feed using Postman

There are different ways to index a feed using the Index API. Using the Postman application eases the performance of posting a new feed to the Index API.

Posting a feed having the index token

Follow these steps to communicate with the Index API if you already have the index_token:

  1. Download (opens new window) the Postman application.

  2. Click the “+” icon on the top left corner and change the request from “GET” to “POST” to set up a new POST request.

  3. In the URL input field, enter the endpoint to submit a new feed. For example, {baseURL}/jobs/submit/{siteId}/{indexToken}/{feedId}/{pivots}, where:

    • baseURL:
      • PROD: https://api.empathy.co/index/v1
      • STAGING: https://api.staging.empathy.co/index/v1
    • siteID: identifier of the client
    • indexToken: client's index token
    • feedID: identifier of the feed to filter the jobs, for example, catalog
    • pivots: URL parameter that is expected to be present since it indicates the dynamic parameters that the API takes into account for the request. For example, language, store, scope, catalogeType, locale, etc., expressed as &pivots=lang,store&lang=en&store=12345, where:
      • lang = en
      • store = 12345

    note

    • For each environment, you must use the corresponding baseURL & indexToken.
    • Depending on the feed's language, you can replace the value of the lang pivot parameter with a different one, for example, “fr”. The same happens for store and the rest of the pivot parameters, if any (scope, catalogeType, locale, etc.).

    This is a full example of the endpoint with the replaced values: https://api.staging.empathy.co/index/v1/jobs/submit/commerce/65ero3702q5exc14w8c9tocl/catalog?&pivots=lang,store&lang=en&store=12345

  4. In the Body tab under the URL input field, provide the feed you like to index. To do so, in the Body tab:

    • Select the form-data bullet option.
    • In the Key input field, name the field file and click the dropdown arrow to change the field type from text to file.
    • In the Value input field, click Select files and choose the feed you want to submit.

    note

    The feed format can be JSON or XML. You must upload large files using the GZIP file format.

  5. On the right of the URL field, click Send. This executes the POST request to the endpoint, submitting the feed indicated in the request's body.

Once you have executed the request, an object will be returned with the information on the job that has been submitted.

note

For large files, the request can take several minutes to be executed.

Posting a feed with IAM authentication

Alternativelly, if you prefer to connect with the Index service using IAM OAuth2 authentication, follow these other steps to index your feed:

note

Before you start indexing your feeds using IAM OAuth2 authentication, be sure you've generated an access token

  1. Download (opens new window) the Postman application.

  2. In the top left corner, click Import and paste the following cURL text:

        curl --location --request POST ‘https://api.staging.empathy.co/index/v1/jobs’ \
            --header ‘Authorization: Bearer <access_token>’ \
            --form ‘clientId=“clientId”’ \
            --form ‘feedId=“catalog”’ \
            --form ‘operationType=“FULL”’ \
            --form ‘feedPath=@{PATH_TO_FEED_FILE}’ \
            --form ‘pivots=“{\“lang\“: [\“ES\“]}“’ 
    

    note

    • Remember that the Authorization: Bearer header must be filled with the [access_token](/develop-empathy-platform/index-product-feed/index-feed-with-api/index.md#getting-the-access-token).
    • As before, depending on the feed's language, you can replace the value of the lang pivot parameter with a different one, for example, "FR”. You can use more pivot parameters like store, scope, catalogeType, locale, etc. if needed.
  3. In the Body tab under the URL input field, provide the feed you want to index. To do so:

    • Look for the ‘feedPath key input row.
    • In the Value input field, click Select files and choose the feed you want to submit.

    note

    The feed format can be JSON or XML. You must upload large files using the GZIP file format.

  4. Click Import Without Saving to not save the request, or click Import Into Collection to save the request in a specific collection.

  5. On the right of the URL field, click Send. This executes the POST request to the endpoint, submitting the feed indicated in the request's body.

Troubleshooting HTTP 400 error

There is a known issue attaching the file in the form-data might throw an HTTP 400. In that case, you can attach a binary file. To do so, in the Body tab:

  1. Select the binary bullet option.
  2. Click Select file and choose the feed you want to submit from your computer.

Verifying the job status

To verify the status of the job and to be able to validate whether or not the feed has been sent correctly, you can perform a GET request to the Index job endpoint with the following: {baseURL}/index/v1/jobs/feed/{siteId}/{indexToken}/catalog

Here is an example: https://api.staging.empathy.co/index/v1/jobs/feed/commerce/65ero3702q5exc14w8c9tocl/catalog

If the job status is Success, the feed has been submitted correctly.