Skip to main content
POST
/
cleemy-procurement
/
services
/
imports
/
costcenters
Import Cost-Centers
curl --request POST \
  --url https://{host}/cleemy-procurement/services/imports/costcenters \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "items": [
    {
      "name": "<string>",
      "code": "<string>",
      "ownerId": 123,
      "state": "Disabled",
      "establishmentIds": [
        123
      ]
    }
  ]
}
'
import requests

url = "https://{host}/cleemy-procurement/services/imports/costcenters"

payload = { "items": [
{
"name": "<string>",
"code": "<string>",
"ownerId": 123,
"state": "Disabled",
"establishmentIds": [123]
}
] }
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
items: [
{
name: '<string>',
code: '<string>',
ownerId: 123,
state: 'Disabled',
establishmentIds: [123]
}
]
})
};

fetch('https://{host}/cleemy-procurement/services/imports/costcenters', 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://{host}/cleemy-procurement/services/imports/costcenters",
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([
'items' => [
[
'name' => '<string>',
'code' => '<string>',
'ownerId' => 123,
'state' => 'Disabled',
'establishmentIds' => [
123
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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://{host}/cleemy-procurement/services/imports/costcenters"

payload := strings.NewReader("{\n \"items\": [\n {\n \"name\": \"<string>\",\n \"code\": \"<string>\",\n \"ownerId\": 123,\n \"state\": \"Disabled\",\n \"establishmentIds\": [\n 123\n ]\n }\n ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Authorization", "<authorization>")
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://{host}/cleemy-procurement/services/imports/costcenters")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"name\": \"<string>\",\n \"code\": \"<string>\",\n \"ownerId\": 123,\n \"state\": \"Disabled\",\n \"establishmentIds\": [\n 123\n ]\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://{host}/cleemy-procurement/services/imports/costcenters")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"name\": \"<string>\",\n \"code\": \"<string>\",\n \"ownerId\": 123,\n \"state\": \"Disabled\",\n \"establishmentIds\": [\n 123\n ]\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "imported": 1,
  "failedValidation": 1,
  "items": [
    {
      "result": {
        "name": "<string>",
        "code": "<string>",
        "id": 123,
        "owner": {
          "id": 123,
          "href": "<string>",
          "name": "<string>",
          "firstName": "<string>",
          "lastName": "<string>",
          "pictureHref": "<string>"
        },
        "state": "Disabled",
        "establishments": [
          {
            "id": 123,
            "name": "<string>",
            "href": "<string>"
          }
        ]
      },
      "problem": {
        "type": "<string>",
        "title": "<string>",
        "status": 123,
        "detail": "<string>",
        "instance": "<string>"
      }
    }
  ]
}
You may want to refer to the dedicated guide.

Headers

Authorization
string
required

API key. Value must be formatted like so: lucca application={api_key}.

Body

application/json
mode
enum<string>

AllOrNothing: all items are imported or none. SkipInvalidItems: items are imported if valid, skipped if not.

Available options:
AllOrNothing,
SkipInvalidItems
items
object[]

List of cost-centers to import.

Response

200 - application/json

Successful cost-centers import.

mode
enum<string>

AllOrNothing: all items are imported or none. SkipInvalidItems: items are imported if valid, skipped if not.

Available options:
AllOrNothing,
SkipInvalidItems
imported
integer<int32>

Number of items imported.

Required range: x >= 0
failedValidation
integer<int3é>

Number of items failed validation.

Required range: x >= 0
items
object[]