Products | Set Product

Set Product Endpoint

This document outlines the procedure for making API calls to set product data through https://easycms.fi/public_api/set_product/. Utilize various parameters to customize your data insertion.

SETTER API ENDPOINT FOR DATA INSERTION

Setter API calls are limited and not available for public API calls, these calls are only available for resellers or certain software providers and developers upon request.

Product Data Insertion

Insert product data effectively using the below API call. Apply the required parameters in the request payload to insert product information.

Product Data Updating

To update an existing product, you should include the pid parameter in the payload with the value set to the unique identifier of the product you want to update. The pid parameter tells the API which product to modify based on its identifier. If the pid matches an existing product in the system, the API will update the product's information with the new data provided in the payload.


Endpoint and Method

  • Endpoint: https://easycms.fi/public_api/set_product/
  • Method: POST

Parameters | Payload

The following parameters are required for inserting/updating product data:

  • TOKEN (api_key): Your unique API key for authentication. How to Create API Credentials.
  • username: Your login username.
  • password: Your login password.
  • account: Your specific account ID.

Update an existing product

  • pid: Product ID - This is a unique identifier for the product. To update a product data, you can pass a pid. To add a new product, you should not pass the pid parameter at all. You may pull all products' data including their pids from the end point /get_products

Inserting New Product

By not passing a pid parameter as a unique identifier for the product you will be adding a new product, you should not pass the pid parameter at all when inserting a new product.

Product Data Parameters:

  • barcode: Product Barcode - This represents the product's barcode or Stock Keeping Unit (SKU).
  • product_desc: Array of Product Descriptions - This object contains product descriptions in various languages, such as Finnish (fi), English (en_gb), Swedish (sv), Thai (th), Spanish (es), Chinese (zh), Vietnamese (vi), and Persian (fa_ir).
    • fi: Description in Finnish.
    • en_gb: Description in English (Great Britain).
    • sv: Description in Swedish.
    • th: Description in Thai.
    • es: Description in Spanish.
    • zh: Description in Chinese.
    • vi: Description in Vietnamese.
    • fa_ir: Description in Persian (Iran).
  • price_gross: Gross Price - The product's gross price before any discounts or taxes.
  • price_net_after_discount: Price Net After Discount - The product's price after applying any discounts.
  • price_gross_after_discount: Gross Price After Discount - The product's gross price after applying any discounts.
  • crp_id: ID for the product.
  • cid: Category ID - This represents the category to which the product belongs.
  • prd_start_display: Start date for displaying the product.
  • prd_end_display: End date for displaying the product.
  • bid: Bid ID for the product.
  • price: Price of the product.
  • price_buy: Buy Price - The price at which the product was bought.
  • min_order: Minimum order quantity for the product.
  • btn_id: Button ID.
  • productDelivery: Array of product delivery information.
  • productDelivery_on_off: Product delivery status (0 or 1).
  • discount: Discount applied to the product.
  • vat: Value Added Tax (VAT) rate.
  • vat_buy: VAT for buying the product.
  • productDetails: Array of additional product details.
  • prdStatus: Product status (1 or 0).
  • prdNumber: Product number.
  • onsale: Product on sale status (0 or 1).
  • buy_x: Buy X.
  • get_x: Get X.
  • stock_type_id: Stock type ID.
  • stock_type_measure: Stock type measure.
  • stock_alert_qty: Stock alert quantity [integer value].
  • stock_alert_bbd: Stock alert days befroe expiry date [integer value].
  • supplier_id: Supplier ID.
  • supplier_reference: Supplier reference.
  • width: Width of the product.
  • height: Height of the product.
  • length: Length of the product.
  • weight: Weight of the product.
  • weight_type: Weight type (e.g., kg).
  • box_qty: Box quantity.
  • box_code: Box code status (true or false).
  • pallet_qty: Pallet quantity.
  • pallet_qty_type: Pallet quantity type (e.g., box).
  • relation_qty: Relation quantity.
  • relation_qty_type: Relation quantity type (e.g., unit).
  • images: Array of product images.
  • videos: Array of product videos.
  • update_date: Date of the last update for the product.

Here's an example payload:

{
    "barcode": "PRODUCT_BARCODE",
    "product_desc": {
        "en_gb": "ProductDescriptionInEnglish",
        "fi": "ProductDescriptionInFinnish",
        "zh": "ProductDescriptionInChinese",
        "vi": "ProductDescriptionInVietnamese",
        "fa_ir": "ProductDescriptionInPersian",
        "es": "ProductDescriptionInSpanish"
    },
    "price_gross": 100.00,
    "price_net_after_discount": 90.00,
    "price_gross_after_discount": 95.00,
    "crp_id": "PRODUCT_ID",
    "cid": "CATEGORY_ID",
    "prd_start_display": "2024-01-01",
    "prd_end_display": "2024-12-31",
    "bid": "BID_ID",
    "price": 80.00,
    "price_buy": 70.00,
    "min_order": 10,
    "btn_id": "BUTTON_ID",
    "productDelivery": {
        "productDelivery_on_off": 1
    },
    "discount": 10.00,
    "vat": 20.00,
    "vat_buy": 15.00,
    "productDetails": [
        {
            "name": "Detail1",
            "value": "Value1"
        },
        {
            "name": "Detail2",
            "value": "Value2"
        }
    ],
    "prdStatus": 1,
    "prdNumber": "PRODUCT_NUMBER",
    "onsale": 1,
    "buy_x": "BUY_X",
    "get_x": "GET_X",
    "stock_type_id": "STOCK_TYPE_ID",
    "stock_type_measure": "STOCK_TYPE_MEASURE",
    "stock_alert_qty": 5,
    "stock_alert_bbd": 30, 
    "supplier_id": "SUPPLIER_ID",
    "supplier_reference": "SUPPLIER_REFERENCE",
    "width": 10.0,
    "height": 5.0,
    "length": 15.0,
    "weight": 1.5,
    "weight_type": "kg",
    "box_qty": 20,
    "box_code": true,
    "pallet_qty": 100,
    "pallet_qty_type": "box",
    "relation_qty": 2,
    "relation_qty_type": "unit",
    "images": [
        "https://prolasku.fi/images_directory/img1.png",
        "https://prolasku.fi/images_directory/img2.png"
    ],
    "videos": [
        "https://youtube.com/video1",
        "https://youtube.com/video2"
    ],
}



Update / Insert Call Examples in Different Languages


curl -X POST 'https://easycms.fi/public_api/set_product' \
-H 'Authorization1: TOKEN' \
-d 'username=USERNAME&password=PASSWORD&account=ACCOUNT_ID'
-d 'barcode=PRODUCT_BARCODE&product_desc_en_gb=ProductDescriptionInEnglish&product_desc_fi=ProductDescriptionInFinnish&product_desc_zh=ProductDescriptionInChinese&product_desc_vi=ProductDescriptionInVietnamese&product_desc_fa_ir=ProductDescriptionInPersian&product_desc_es=ProductDescriptionInSpanish&price_gross=100.00&price_net_after_discount=90.00&price_gross_after_discount=95.00&crp_id=PRODUCT_ID&cid=CATEGORY_ID&prd_start_display=2024-01-01&prd_end_display=2024-12-31&bid=BID_ID&price=80.00&price_buy=70.00&min_order=10&btn_id=BUTTON_ID&productDelivery_on_off=1&discount=10.00&vat=20.00&vat_buy=15.00&productDetails=Detail1%3AValue1%2CDetail2%3AValue2&prdStatus=1&prdNumber=PRODUCT_NUMBER&onsale=1&buy_x=BUY_X&get_x=GET_X&stock_type_id=STOCK_TYPE_ID&stock_type_measure=STOCK_TYPE_MEASURE&stock_alert_qty=5&stock_alert_bbd=2024-06-30&supplier_id=SUPPLIER_ID&supplier_reference=SUPPLIER_REFERENCE&width=10.0&height=5.0&length=15.0&weight=1.5&weight_type=kg&box_qty=20&box_code=true&pallet_qty=100&pallet_qty_type=box&relation_qty=2&relation_qty_type=unit&images=https%3A%2F%2Fprolasku.fi%2Fimages_directory%2Fimg1.png%2Chttps%3A%2F%2Fprolasku.fi%2Fimages_directory%2Fimg2.png&videos=https%3A%2F%2Fyoutube.com%2Fvideo1%2Chttps%3A%2F%2Fyoutube.com%2Fvideo2'

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://easycms.fi/public_api/set_product",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_POSTFIELDS => http_build_query([
    'username' => 'USERNAME', 
    'password' => 'PASSWORD', 
    'account' => 'ACCOUNT_ID',
    // Add other payload parameters here
  ]),
  CURLOPT_HTTPHEADER => array("Authorization1: TOKEN"),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

import requests
url = "https://easycms.fi/public_api/set_product"
headers = {"Authorization1": "TOKEN"}
payload = {
    'username': 'USERNAME', 
    'password': 'PASSWORD', 
    'account': 'ACCOUNT_ID',
    # Add other payload parameters here
}
response = requests.post(url, headers=headers, data=payload)
print(response.text)

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://easycms.fi/public_api/set_product"))
    .headers("Authorization1", "TOKEN")
    .POST(HttpRequest.BodyPublishers.ofString("username=USERNAME&password=PASSWORD&account=ACCOUNT_ID"))
    .build();
HttpResponse response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());

const https = require('https');
const data = new URLSearchParams({ 
  username: 'USERNAME', 
  password: 'PASSWORD', 
  account: 'ACCOUNT_ID'
  // Add other payload parameters here
}).toString();
const options = {
  hostname: 'prolasku.fi',
  path: '/public_api/set_product',
  method: 'POST',
  headers: {
    'Authorization1': 'TOKEN',
    'Content-Type': 'application/x-www-form-urlencoded',
    'Content-Length': data.length
  }
};
const req = https.request(options, (res) => {
  let data = '';
  res.on('data', (chunk) => { data += chunk; });
  res.on('end', () => { console.log(data); });
});
req.on('error', (e) => { console.error(e); });
req.write(data);
req.end();

import React, { useEffect, useState } from 'react';
function App() {
  const [categoryData, setCategoryData] = useState('');
  useEffect(() => {
    const fetchData = async () => {
      try {
        const response = await fetch('https://easycms.fi/public_api/set_product', {
          method: 'POST',
          headers: {'Authorization1': 'TOKEN', 'Content-Type': 'application/x-www-form-urlencoded'},
          body: new URLSearchParams({
            username: 'USERNAME', 
            password: 'PASSWORD', 
            account: 'ACCOUNT_ID'
            // Add other payload parameters here
          }).toString()
        });
        const data = await response.text();
        setCategoryData(data);
      } catch (error) {
        console.error(error);
      }
    };
    fetchData();
  }, []);
  return (
{categoryData}
); } export default App;

import okhttp3.OkHttpClient
import okhttp3.FormBody
import okhttp3.Request

fun main() {
    val client = OkHttpClient()

    val formBody = FormBody.Builder()
        .add("username", "USERNAME")
        .add("password", "PASSWORD")
        .add("account", "ACCOUNT_ID")
        // Add other payload parameters here
        .build()

    val request = Request.Builder()
        .url("https://easycms.fi/public_api/set_product")
        .post(formBody)
        .addHeader("Authorization1", "TOKEN")
        .build()

    client.newCall(request).execute().use { response ->
        if (!response.isSuccessful) throw IOException("Unexpected code $response")

        println(response.body?.string())
    }
}

using System;
using System.Net.Http;
using System.Threading.Tasks;
class Program
{
    static async Task Main()
    {
        var token = "TOKEN";
        var content = new FormUrlEncodedContent(new[]
        {
            new KeyValuePair("username", "USERNAME"),
            new KeyValuePair("password", "PASSWORD"),
            new KeyValuePair("account", "ACCOUNT_ID")
            // Add other payload parameters here
        });
        using (var httpClient = new HttpClient())
        {
            httpClient.DefaultRequestHeaders.Add("Authorization1", token);
            var response = await httpClient.PostAsync("https://easycms.fi/public_api/set_product", content);
            if (response.IsSuccessStatusCode)
            {
                var responseData = await response.Content.ReadAsStringAsync();
                Console.WriteLine(responseData);
            }
            else
            {
                Console.WriteLine($"Error: {response.StatusCode}");
            }
        }
    }
}




Handling Endpoint Results

When you make a request to the endpoint, you receive a JSON response containing various keys and values. Here's an explanation of the response keys and their meanings:


- `pid`: Product ID - This is a unique identifier for the product.
- `product_name`: Product Name - This represents the name of the product in different languages.

  - `fi`: product name in Finnish.
  - `en_gb`: product name in English (Great Britain).

To see available languages please check endpoint /get_languages.

These key-value pairs provide comprehensive information about the products and can be used for various purposes in your application.
    

{
    "OUTPUT": {
        "0": {
            "pid": "1",
            "visible": "1",
            "parent_id": 0,
            "pNumber": "1",
            "product_name": {
                "en_gb": "NewProductName_in_en_gb_language",
                "fi": "NewProductName_in_fi_language"
            }
        },
        "response_type": "success",
        "message": "Data inserted successfully"
    }
}
    

Error Handling

Here are the possible error messages and their meanings:

  • UN-AUTHORIZED - _user_name_password_is_set_but_wrong_value!: Incorrect username or password.
  • this_account_does_not_exist_or_your_credentials_do_not_match_this_account: The account doesn't exist or mismatched credentials.
  • UN-AUTHORIZED - header is set but the header value is not correct!: Incorrect authorization header value.
  • Maximum query size is 1 rows per query: Exceeded maximum limit of 1 rows per query.