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"
}
]
}
}
EOFimport 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"
}
}
}
]
}Test Mapping
Returns sampled dataset after attribute mapping for a given mapping.
This endpoint should be used when mapping does not exist.
A response is a list of JSON objects, where every object will have an input field, that represents the original key/value pairs from the dataset, and the output filed that will contain mapped fields where the key will be attribute name, and value will be JSON object of key/value pairs.
A cached_mapping is resolved as a join at query time and has no per-row preview, so its response is always an empty list of records.
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"
}
]
}
}
EOFimport 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
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Query Parameters
The number of rows to sample from the dataset.
x <= 1000Body
The target attribute's ID.
The source dataset's ID.
Mapping definition for create/update requests. Dependencies are computed server-side and not provided by the client.
- Option 1
- Option 2
- Option 3
Show child attributes
Show child attributes
Optional source for the mapping. If not specified, defaults to company.
Only company and rosetta_stone are allowed for user-created mappings.
company, rosetta_stone Response
OK
Was this page helpful?

