Skip to main content
POST
/
mappings
/
test
Test Mapping
curl --request POST \
  --url https://api-dev.narrative.io/mappings/test \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data @- <<EOF
{
  "attribute_id": 123,
  "dataset_id": 456,
  "mapping": {
    "type": "object_mapping",
    "property_mappings": [
      {
        "path": "product.brand",
        "expression": "itemBrand"
      },
      {
        "path": "product.category",
        "expression": "itemCategory"
      },
      {
        "path": "product.id.type",
        "expression": "'SKU'"
      },
      {
        "path": "product.id.value",
        "expression": "itemID"
      }
    ]
  }
}
EOF
import requests

url = "https://api-dev.narrative.io/mappings/test"

payload = {
"attribute_id": 123,
"dataset_id": 456,
"mapping": {
"type": "object_mapping",
"property_mappings": [
{
"path": "product.brand",
"expression": "itemBrand"
},
{
"path": "product.category",
"expression": "itemCategory"
},
{
"path": "product.id.type",
"expression": "'SKU'"
},
{
"path": "product.id.value",
"expression": "itemID"
}
]
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
attribute_id: 123,
dataset_id: 456,
mapping: {
type: 'object_mapping',
property_mappings: [
{path: 'product.brand', expression: 'itemBrand'},
{path: 'product.category', expression: 'itemCategory'},
{path: 'product.id.type', expression: '\'SKU\''},
{path: 'product.id.value', expression: 'itemID'}
]
}
})
};

fetch('https://api-dev.narrative.io/mappings/test', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api-dev.narrative.io/mappings/test",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'attribute_id' => 123,
'dataset_id' => 456,
'mapping' => [
'type' => 'object_mapping',
'property_mappings' => [
[
'path' => 'product.brand',
'expression' => 'itemBrand'
],
[
'path' => 'product.category',
'expression' => 'itemCategory'
],
[
'path' => 'product.id.type',
'expression' => '\'SKU\''
],
[
'path' => 'product.id.value',
'expression' => 'itemID'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api-dev.narrative.io/mappings/test"

payload := strings.NewReader("{\n \"attribute_id\": 123,\n \"dataset_id\": 456,\n \"mapping\": {\n \"type\": \"object_mapping\",\n \"property_mappings\": [\n {\n \"path\": \"product.brand\",\n \"expression\": \"itemBrand\"\n },\n {\n \"path\": \"product.category\",\n \"expression\": \"itemCategory\"\n },\n {\n \"path\": \"product.id.type\",\n \"expression\": \"'SKU'\"\n },\n {\n \"path\": \"product.id.value\",\n \"expression\": \"itemID\"\n }\n ]\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api-dev.narrative.io/mappings/test")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"attribute_id\": 123,\n \"dataset_id\": 456,\n \"mapping\": {\n \"type\": \"object_mapping\",\n \"property_mappings\": [\n {\n \"path\": \"product.brand\",\n \"expression\": \"itemBrand\"\n },\n {\n \"path\": \"product.category\",\n \"expression\": \"itemCategory\"\n },\n {\n \"path\": \"product.id.type\",\n \"expression\": \"'SKU'\"\n },\n {\n \"path\": \"product.id.value\",\n \"expression\": \"itemID\"\n }\n ]\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api-dev.narrative.io/mappings/test")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"attribute_id\": 123,\n \"dataset_id\": 456,\n \"mapping\": {\n \"type\": \"object_mapping\",\n \"property_mappings\": [\n {\n \"path\": \"product.brand\",\n \"expression\": \"itemBrand\"\n },\n {\n \"path\": \"product.category\",\n \"expression\": \"itemCategory\"\n },\n {\n \"path\": \"product.id.type\",\n \"expression\": \"'SKU'\"\n },\n {\n \"path\": \"product.id.value\",\n \"expression\": \"itemID\"\n }\n ]\n }\n}"

response = http.request(request)
puts response.read_body
{
  "records": [
    {
      "input": {
        "idType": "idType1",
        "idValue": "idValue1"
      },
      "output": {
        "unique_id_f7635d42_51ce_4535_ae8b_9ac64df85501": {
          "type": "idType1",
          "value": "idValue1"
        }
      }
    },
    {
      "input": {
        "idType": "idType2",
        "idValue": "idValue2"
      },
      "output": {
        "unique_id_f7635d42_51ce_4535_ae8b_9ac64df85501": {
          "type": "idType2",
          "value": "idValue2"
        }
      }
    }
  ]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Query Parameters

size
integer

The number of rows to sample from the dataset.

Required range: x <= 1000

Body

application/json
attribute_id
integer

The target attribute's ID.

dataset_id
integer

The source dataset's ID.

mapping
object

Mapping definition for create/update requests. Dependencies are computed server-side and not provided by the client.

source
enum<string>

Optional source for the mapping. If not specified, defaults to company. Only company and rosetta_stone are allowed for user-created mappings.

Available options:
company,
rosetta_stone

Response

200 - application/json

OK

records
object[]