cURL
curl -X POST \
/accounting/cost-centres \
--header "Content-Type: application/json" \
--header "Authorization: Bearer <token>" \
--data '{
"name": "Cost Centre",
"code": "CC",
"type": "KOST1"
}'import requests
url = "https://coreapi.io/accounting/cost-centres"
payload = {
"name": "Cost Centre",
"code": "CC",
"type": "KOST1",
"status": "active"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: 'Cost Centre', code: 'CC', type: 'KOST1', status: 'active'})
};
fetch('https://coreapi.io/accounting/cost-centres', 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://coreapi.io/accounting/cost-centres",
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([
'name' => 'Cost Centre',
'code' => 'CC',
'type' => 'KOST1',
'status' => 'active'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"name": "Cost Centre",
"type": "KOST1",
"status": "active",
"id": "ad8f1c9c-4f0a-4e1a-8b1a-9c4d9c4d9c4d",
"code": "CC",
"createdAt": "2021-01-01T00:00:00+00:00",
"updatedAt": "2021-01-01T00:00:00+00:00"
}Cost Centre
Add a cost centre
Add a cost centre. A cost centre can be of type KOST1 or KOST2 and must have a unique code.
Required permissions:cost-centre:writePOST
/
accounting
/
cost-centres
cURL
curl -X POST \
/accounting/cost-centres \
--header "Content-Type: application/json" \
--header "Authorization: Bearer <token>" \
--data '{
"name": "Cost Centre",
"code": "CC",
"type": "KOST1"
}'import requests
url = "https://coreapi.io/accounting/cost-centres"
payload = {
"name": "Cost Centre",
"code": "CC",
"type": "KOST1",
"status": "active"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: 'Cost Centre', code: 'CC', type: 'KOST1', status: 'active'})
};
fetch('https://coreapi.io/accounting/cost-centres', 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://coreapi.io/accounting/cost-centres",
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([
'name' => 'Cost Centre',
'code' => 'CC',
'type' => 'KOST1',
'status' => 'active'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"name": "Cost Centre",
"type": "KOST1",
"status": "active",
"id": "ad8f1c9c-4f0a-4e1a-8b1a-9c4d9c4d9c4d",
"code": "CC",
"createdAt": "2021-01-01T00:00:00+00:00",
"updatedAt": "2021-01-01T00:00:00+00:00"
}Autorisierungen
Body
application/jsontext/html
The new CostCentre resource
Antwort
CostCentre resource created
War diese Seite hilfreich?