Update Questionnaire Product Data via API

Last updated August 2, 2023

Connect to our API to automatically update product information with your Skin Match Technology Solutions.

In order to update your product information through the API you need your questionnaire ID, an API Key and the EAN of the product you want to update.

The basic process is as follows:

Step 1: Request the current product information.

Make a request to https://getskinmatch.com/smtapi/questionnaire/ean/get/ sending “qid” (Questionnaire ID), “key” (API Key) and “ean” either as JSON in the request body or as URL parameters.
Your request should return a JSON that contains all current product information in all languages. It will also contain a status code so that you can verify your call was successful.

Important Information
Please note that you can only update one product at a time, so you’ll have to call the API repeatedly to loop through your inventory.

Step 2: Update the data

Take the JSON received above and manipulate it to reflect the updated product data. One common case is updating the price; in this case you’d get the JSON and then update the price within the JSON for all languages. How you manipulate the JSON depends on your programming language and environment; you might convert it to an array, update the fields, and convert back to JSON or maybe you can update the JSON directly.

Step 3: Send the JSON back

When all necessary data updates have been performed, you will have to send the JSON back to us in its entirety. That means if you only updated the price, you still need to include all other fields like brand, title, etc (which is why we first request the current JSON and only update fields within that). The current version of the product will be overwritten with the JSON you send in, so make sure it is still a complete, multi-language (if applicable) product JSON.

To send the file back, make a call to https://getskinmatch.com/smtapi/questionnaire/ean/update/
Once again you need to send “qid”, “key”, “ean” along with “data” as a JSON in the body of the request.
The request will return a status code that allows you to check if it was successful. You can then go into the Questionnaire’s dashboard and verify that the information has been saved correctly.

Below is an example in PHP:

<?php

$data[“qid”] = “xxx”; /* The questionnaire ID */
$data[“key”] = “xxx”; /* Your API Key */
$data[“ean”] = “xxx”; /* The EAN you want to update */

$data_json = json_encode($data);

$ch = curl_init(“https://getskinmatch.com/smtapi/questionnaire/ean/get/”);

//curl_setopt($ch, CURLOPT_PORT, 8890);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
‘Content-Type: application/json’,
‘Content-Length: ‘ . strlen($data))
);
$result = curl_exec($ch);
$result = json_decode($result, true);

if($result[“status”][“code”] == “200”) {
// product was fetched correctly
// below code will display the product information;

echo ‘<pre>’;
print_r($result[“response”]);
echo ‘</pre>’;

// update the fields that you want to update within $result[“response”]
// and then send it back to the questionnaire.

// $result[“response”][“data”][“en”][“brand”] = “ABSOLUTION”;
// $result[“response”][“data”][“en”][“shop_link”] = “…”;

$data[“data”] = $result[“response”][“data”];
$data[“status”] = $result[“response”][“status”]; 
/* usually don’t have to update status; it defines if a product is active or inactive and can be set through the dashboard */
$updatedFields = json_encode($data);

// update endpoint
$ch = curl_init(“https://getskinmatch.com/smtapi/questionnaire/ean/update/”);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”);
curl_setopt($ch, CURLOPT_POSTFIELDS, $updatedFields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
‘Content-Type: application/json’,
‘Content-Length: ‘ . strlen($updatedFields))
);

$result_update = curl_exec($ch);
$result_update = json_decode($result_update, true);

if($result_update[“status”][“code”] == “200”) {
// update was successful
}

} else {
// something went wrong
// print_r($result) will give more information
}
?>

Related Topics