Product Upsert API

The API Upserts the Products and the data is sent to the servers for the integration usage. The data is sent to the servers for the integration usage.

API Endpoint

The request is a POST request to the /api/integration/products endpoint.

Request Structure

POST /api/integration/products HTTP/1.1
{
data: [
{
product_sku_id: "<product-id>",
amount: "<amount>"
}
]
}

Query

product_sku_idtrueStringProduct Id
amounttrueNumberPrice of the Product

Sample Request

  • cURL
  • PHP-cUrl
  • Node-Axios
  • C#-RestSharp
  • Python-http.client
  • Java-OkHttp
  • Go
  • Ruby
  • C
  • PowerShell

curl --location --request POST 'localhost:8000/api/integration/products' --header 'token: U78FtRBfsMAnecq_q3i8J' --header 'Content-Type: application/json' --data-raw '{
"data": [
{
"product_sku_id": "sku_1",
"amount": "25"
},
{
"product_sku_id": "sku_2",
"amount": "25"
},
{
"product_sku_id": "sku_3",
"amount": "25"
},
{
"product_sku_id": "sku_4",
"amount": "25"
}
]
}'

<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'localhost:8000/api/integration/products',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"data": [
{
"product_sku_id": "sku_1",
"amount": "25"
},
{
"product_sku_id": "sku_2",
"amount": "25"
},
{
"product_sku_id": "sku_3",
"amount": "25"
},
{
"product_sku_id": "sku_4",
"amount": "25"
}
]
}',
CURLOPT_HTTPHEADER => array(
'token: U78FtRBfsMAnecq_q3i8J',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

var axios = require('axios');
var data = JSON.stringify({
"data": [
{
"product_sku_id": "sku_1",
"amount": "25"
},
{
"product_sku_id": "sku_2",
"amount": "25"
},
{
"product_sku_id": "sku_3",
"amount": "25"
},
{
"product_sku_id": "sku_4",
"amount": "25"
}
]
});
var config = {
method: 'post',
url: 'localhost:8000/api/integration/products',
headers: {
'token': 'U78FtRBfsMAnecq_q3i8J',
'Content-Type': 'application/json'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});

var client = new RestClient("localhost:8000/api/integration/products");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("token", "U78FtRBfsMAnecq_q3i8J");
request.AddHeader("Content-Type", "application/json");
var body = @"{
" + "
" +
@" ""data"": [
" + "
" +
@" {
" + "
" +
@" ""product_sku_id"": ""sku_1"",
" + "
" +
@" ""amount"": ""25""
" + "
" +
@" },
" + "
" +
@" {
" + "
" +
@" ""product_sku_id"": ""sku_2"",
" + "
" +
@" ""amount"": ""25""
" + "
" +
@" },
" + "
" +
@" {
" + "
" +
@" ""product_sku_id"": ""sku_3"",
" + "
" +
@" ""amount"": ""25""
" + "
" +
@" },
" + "
" +
@" {
" + "
" +
@" ""product_sku_id"": ""sku_4"",
" + "
" +
@" ""amount"": ""25""
" + "
" +
@" }
" + "
" +
@" ]
" + "
" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("token", "U78FtRBfsMAnecq_q3i8J")
$headers.Add("Content-Type", "application/json")
$body = "{
`n `"data`": [
`n {
`n `"product_sku_id`": `"sku_1`",
`n `"amount`": `"25`"
`n },
`n {
`n `"product_sku_id`": `"sku_2`",
`n `"amount`": `"25`"
`n },
`n {
`n `"product_sku_id`": `"sku_3`",
`n `"amount`": `"25`"
`n },
`n {
`n `"product_sku_id`": `"sku_4`",
`n `"amount`": `"25`"
`n }
`n ]
`n}"
$response = Invoke-RestMethod 'localhost:8000/api/integration/products' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{
"data": [
{
"product_sku_id": "sku_1",
"amount": "25"
},
{
"product_sku_id": "sku_2",
"amount": "25"
},
{
"product_sku_id": "sku_3",
"amount": "25"
},
{
"product_sku_id": "sku_4",
"amount": "25"
}
]
}");
Request request = new Request.Builder()
.url("localhost:8000/api/integration/products")
.method("POST", body)
.addHeader("token", "U78FtRBfsMAnecq_q3i8J")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();

package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "localhost:8000/api/integration/products"
method := "POST"
payload := strings.NewReader(`{`+"
"+`
"data": [`+"
"+`
{`+"
"+`
"product_sku_id": "sku_1",`+"
"+`
"amount": "25"`+"
"+`
},`+"
"+`
{`+"
"+`
"product_sku_id": "sku_2",`+"
"+`
"amount": "25"`+"
"+`
},`+"
"+`
{`+"
"+`
"product_sku_id": "sku_3",`+"
"+`
"amount": "25"`+"
"+`
},`+"
"+`
{`+"
"+`
"product_sku_id": "sku_4",`+"
"+`
"amount": "25"`+"
"+`
}`+"
"+`
]`+"
"+`
}`)
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("token", "U78FtRBfsMAnecq_q3i8J")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}

require "uri"
require "json"
require "net/http"
url = URI("localhost:8000/api/integration/products")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Post.new(url)
request["token"] = "U78FtRBfsMAnecq_q3i8J"
request["Content-Type"] = "application/json"
request.body = JSON.dump({
"data": [
{
"product_sku_id": "sku_1",
"amount": "25"
},
{
"product_sku_id": "sku_2",
"amount": "25"
},
{
"product_sku_id": "sku_3",
"amount": "25"
},
{
"product_sku_id": "sku_4",
"amount": "25"
}
]
})
response = http.request(request)
puts response.read_body

CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "localhost:8000/api/integration/products");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "token: U78FtRBfsMAnecq_q3i8J");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
const char *data = "{
"data": [
{
"product_sku_id": "sku_1",
"amount": "25"
},
{
"product_sku_id": "sku_2",
"amount": "25"
},
{
"product_sku_id": "sku_3",
"amount": "25"
},
{
"product_sku_id": "sku_4",
"amount": "25"
}
]
}";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);

Sample Response

POST /api/integration/products HTTP/1.1
{
message: "4 new records inserted. 0 existing records updated. Same value or invalid data skipped 0",
inserted: 4,
updated: 0,
skipped: 0
}

Error Codes

200SuccessRequest Based Response
400Bad Request{ "path": "String", "error": "String" }
401Unauthorized{ "error": "String" }
500Internal server error{ "error": "String" }