Articles in this section

Map HTTP body parameters using JSON or XML

Warning

This feature will be available after the 2025.1.1 release. This is a pre-release article.

You can directly map JSON or XML body parameters in the Celigo platform using a "mapper" similar to Transformations 2.0 or Mapper 2.0. Where previously you might have to write and send your request body parameters manually, you can now add the parameter and its value while creating your export or lookup.

The body parameter mapper is available directly in an export. In lookups and imports, click + to expand the menu in the lookup bubble and then click Mapper (Edit mappings ).

Important

You can't automatically build an XML request body using body parameters. You still need to generate the request body on your own; however, you can use the parameters you generate here in your request body for easy use.

Body_params_mapper.png

Body parameters mapper in an export

lookup_body_params_mapper.png

Body parameters mapper in a lookup

import_body_params.png

Body parameters in an import

lookup_body_params_mapper.png

Body parameters mapper in an import

Why map your HTTP body parameters

A request body is needed when an HTTP API application request requires additional data to be sent to the server to process the request. This is common for operations like creating, updating, or querying resources, where you must provide specific details such as user inputs or parameters. For example, when submitting a form, creating a user account, or searching with filters, the request body contains the necessary data in a structured format (e.g., JSON or XML) for the API to understand and execute the request appropriately.

Map your body parameters

Mapping your body parameters is very simple, but you must have some information ready before you begin.

Before you begin

Before you can map your body parameters, you'll need to find your application's API documentation. This will tell you exactly what parameters you need and how to map them. To find the API docs for your application, search for <Your application> API documentation in any search engine. If the application is not available with an existing connector, you won't be able to find the API documentation in the Celigo Help Center. You'll need to use a search engine like Google, Bing, or DuckDuckGo to find the API docs.

It would also help to learn a bit about handlebars and how to use them to build your request body quickly.

Finally, you should read this article on Building your HTTP request body and relative URI. It will give you a quick overview of how to build a request body in the Celigo platform.

Build HTTP request body via (exports and lookups)

This read-only field shows you how your request body is being built. Various options are available, and the Celigo platform will automatically adjust this field based on how you create your export or lookup:

No request body: This is automatically selected if you don't use the body parameter mapper or the HTTP request body field. In this case, you wouldn't be building a request body.

Body parameters builder only: If you define the request using only the Body parameters field, it will choose 'Body parameters builder only.' In this case, you're not building the body manually. Instead, you're adding the parameters to the mapper, and the Celigo platform will send them as-is. You can still use handlebars in the individual body parameters, instead of building the entire request body in the handlebars template only.

Handlebars template only: If you define the request using only the HTTP request body field, it will choose 'Handlebars template only.'

Body parameters builder and handlebars template: If you build your request using the Body parameters and the HTTP request body fields, the 'Body parameters builder and handlebars template' field will be selected.

Tip

You can use handlebars directly in your body parameter mapper, which differs from using only a handlebars template. When using the body parameters builder only, you send the body parameters as-is without customizing the entire HTTP request body. If you use the handlebars template only, you're choosing to build the whole request body.

Build request body via (imports)

This read-only field shows you how your request body is being built. Various options are available, and the Celigo platform will automatically adjust this field based on how you create your import:

Mapper output only: This is automatically chosen if you only use Mapper 2.0 to output data for your HTTP request body.

Handlebars template only: This is automatically chosen if you only use handlebars in the HTTP request body.

Mapper output & handlebars template: Chosen automatically if you use both handlebars and the Mapper 2.0 output to build your request body.

Send source records as-is: Only when the request body isn't modified.

Body parameters

Use this field to enter your body parameters. You can enter multiple key-value pairs and use handlebars to customize the parameter further. Let's look at the following examples using this JSON or XML request:

Important

You can't automatically build an XML request body using body parameters. You still need to generate the request body on your own; however, you can use the parameters you generate here in your request body for easy use.

Example requests and responses

JSON

Request

GET "https://your-development-store.myshopify.com/admin/api/2025-01/customers.json?fields=id%2Cemail%2Ctags"

Response

HTTP/1.1 200 OK
{
  "customers": [
    {
      "id": 207119551,
      "email": "bob.norman@mail.example.com",
      "tags": "Léon, Noël"
    }
  ]
}
XML

Request

<GetCustomersRequest>
    <Endpoint>https://your-development-store.myshopify.com/admin/api/2025-01/customers.json</Endpoint>
    <Headers>
        <Header>
            <Name>X-Shopify-Access-Token</Name>
            <Value>{access_token}</Value>
        </Header>
    </Headers>
    <QueryParameters>
        <Parameter>
            <Name>fields</Name>
            <Value>id,email,tags</Value>
        </Parameter>
    </QueryParameters>
</GetCustomersRequest>

Response

<Response>
    <Status>200 OK</Status>
    <Customers>
        <Customer>
            <Id>207119551</Id>
            <Email>bob.norman@mail.example.com</Email>
            <Tags>Léon, Noël</Tags>
        </Customer>
    </Customers>
</Response>

Hard-coded vs handlebar values

You can use standard hard-coded values in cases where you don't need the request body parameters to change based on your exported records. For example, you can hardcode the ID field to always equal 207119551. The body always uses the hard-coded value 207119551 for the ID field. In this case, the body parameter would look like this:

ID | 207119551

Hard_coded_body_params.png

In cases where you want the value to change based on the data you receive from the export application, you can use handlebars to supplement the body parameters. For example, you can use {{fields.ID}} in the ID field to substitute the ID used in each record. In this case, the helper will iterate through every ID field, for example, 207119551 and 678903456. The body parameters would look something like this:

ID | {{fields.ID}}

Handlebars_in_body_params_mapper.png

HTTP request body

The HTTP request body defines the request sent to your source application. Exports typically use an HTTP GET method and do not require an HTTP request body. You do not need to build a request body.

Sometimes, a different HTTP method and/or a request body are required. This field defines the HTTP request body sent to the source application endpoint. The best option for building a request body is to paste an example request from your source application’s API and add your handlebars expressions.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.