Brands | Set Brand

Set Brand Endpoint

This document outlines the procedure for making API calls to set brand data through https://easycms.fi/public_api/set_brand/. 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.

Brands Data Insertion

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

Brand Data Updating

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

For example:

{
    "bid": "EXISTING_BRAND_ID", // Specify the existing brand's ID to update it
    // Other brand data parameters that are intended to be updated...
}

Endpoint and Method

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

Parameters | Payload

The following parameters are required for inserting brand 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.
  • brand_name: The brand name to be inserted.
  • image: The brand image to be inserted.

Here's an example payload:

{
    "TOKEN": "YOUR_API_KEY",
    "username": "YOUR_USERNAME",
    "password": "YOUR_PASSWORD",
    "account": "YOUR_ACCOUNT_ID",
    "brand_name": {
        "en_gb": "BrandNameInEnglish",
        "fi": "BrandNameInFinnish",
        "zh": "BrandNameInChinese",
        "vi": "BrandNameInVietnamese",
        "fa_ir": "BrandNameInPersian",
        "es": "BrandNameInSpanish"
    },
    "image" : "https://prolasku.fi/images_directory/img.png"
}



Call Examples in Different Languages


curl -X POST 'https://easycms.fi/public_api/set_brand' \
-H 'Authorization1: TOKEN' \
-d 'username=USERNAME&password=PASSWORD&account=ACCOUNT_ID'

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

import requests
url = "https://easycms.fi/public_api/set_brand"
headers = {"Authorization1": "TOKEN"}
payload = {'username': 'USERNAME', 'password': 'PASSWORD', 'account': 'ACCOUNT_ID'}
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_brand"))
    .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'
}).toString();
const options = {
  hostname: 'prolasku.fi',
  path: '/public_api/set_brand',
  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_brand', {
          method: 'POST',
          headers: {'Authorization1': 'TOKEN', 'Content-Type': 'application/x-www-form-urlencoded'},
          body: new URLSearchParams({username: 'USERNAME', password: 'PASSWORD', account: 'ACCOUNT_ID'}).toString()
        });
        const data = await response.text();
        setCategoryData(data);
      } catch (error) {
        console.error(error);
      }
    };
    fetchData();
  }, []);
  return (
{categoryData}
); } export default App;

// Kotlin example requires using a third-party library like OkHttp for POST requests with a body
// Kotlin Example using OkHttp for POST request
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")
        .build()

    val request = Request.Builder()
        .url("https://easycms.fi/public_api/set_brand")
        .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")
        });
        using (var httpClient = new HttpClient())
        {
            httpClient.DefaultRequestHeaders.Add("Authorization1", token);
            var response = await httpClient.PostAsync("https://easycms.fi/public_api/set_brand", 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:


- `bid`: Brand ID - This is a unique identifier for the brand.
- `brand_name`: Brand Name - This represents the name of the brand names in different languages.

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

To see available languages please check endpoint /get_languages.

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


{
    "OUTPUT": {
        "0": {
            "bid": "1",
            "visible": "1",
            "parent_id": 0,
            "bNumber": "1",
            "brand_name": {
                "en_gb": "NewBrandName_in_en_gb_language",
                "fi": "NewBrandName_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.