Bulk Create Overrides - Fabric
Bulk Create Overrides
cURL
curl --request POST \
--url https://api.fabric.inc/v3/location-capacity/actions/bulk-create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-fabric-tenant-id: <x-fabric-tenant-id>' \
--data '
{
"capacity": 30,
"schedule": {
"startDate": "2022-05-12T09:30:31Z",
"endDate": "2022-05-12T09:30:31Z"
},
"reasonCode": "holiday",
"locationNumbers": [
"1234",
"5678"
],
"notes": "Any additional info",
"createdBy": "Carl Doe",
"updatedBy": "Carl Doe"
}
'
Python Example
import requests
url = "https://api.fabric.inc/v3/location-capacity/actions/bulk-create"
payload = {
"capacity": 30,
"schedule": {
"startDate": "2022-05-12T09:30:31Z",
"endDate": "2022-05-12T09:30:31Z"
},
"reasonCode": "holiday",
"locationNumbers": ["1234", "5678"],
"notes": "Any additional info",
"createdBy": "Carl Doe",
"updatedBy": "Carl Doe"
}
headers = {
"x-fabric-tenant-id": "<x-fabric-tenant-id>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
JavaScript Example
const options = {
method: 'POST',
headers: {
'x-fabric-tenant-id': '<x-fabric-tenant-id>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
capacity: 30,
schedule: {startDate: '2022-05-12T09:30:31Z', endDate: '2022-05-12T09:30:31Z'},
reasonCode: 'holiday',
locationNumbers: ['1234', '5678'],
notes: 'Any additional info',
createdBy: 'Carl Doe',
updatedBy: 'Carl Doe'
})
};
fetch('https://api.fabric.inc/v3/location-capacity/actions/bulk-create', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
PHP Example
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.fabric.inc/v3/location-capacity/actions/bulk-create",
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([
'capacity' => 30,
'schedule' => [
'startDate' => '2022-05-12T09:30:31Z',
'endDate' => '2022-05-12T09:30:31Z'
],
'reasonCode' => 'holiday',
'locationNumbers' => [
'1234',
'5678'
],
'notes' => 'Any additional info',
'createdBy' => 'Carl Doe',
'updatedBy' => 'Carl Doe'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-fabric-tenant-id: <x-fabric-tenant-id>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Go Example
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.fabric.inc/v3/location-capacity/actions/bulk-create"
payload := strings.NewReader("{\n \"capacity\": 30,\n \"schedule\": {\n \"startDate\": \"2022-05-12T09:30:31Z\",\n \"endDate\": \"2022-05-12T09:30:31Z\"\n },\n \"reasonCode\": \"holiday\",\n \"locationNumbers\": [\n \"1234\",\n \"5678\"\n ],\n \"notes\": \"Any additional info\",\n \"createdBy\": \"Carl Doe\",\n \"updatedBy\": \"Carl Doe\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-fabric-tenant-id", "<x-fabric-tenant-id>")
req.Header.Add("Authorization", "Bearer <token>")
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))
}
Error Handling
The possible HTTP status codes that you may receive are:
- 200: Request was successful.
- 201: Resource created successfully.
- 400: Bad Request, missing or invalid parameters.
- 401: Unauthorized, invalid credentials provided.
- 500: Internal Server Error.