Export records by query - Fabric
Export records by query
cURL
curl --request POST \
--url https://prod01.oms.fabric.inc/api/v2/exports \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-site-context: <x-site-context>' \
--data '
{
"filters": {
"retail": {
"locationNum": 12
},
"orderSubTotal": {
"gte": 1300,
"lt": 1400
},
"orderNumber": "order-*Z",
"statusCode": [\
"ORDER_CREATED"\\
],
"createdAt": {
"lt": "2022-09-11T23:12:00.123Z"
},
"shipInfo": {
"shipToId": [\
"23434",\
"23436"\\
]
}
},
"module": "ORDER",
"limit": 10,
"offset": 0,
"sortBy": "updatedAt",
"sortDirection": "desc",
"csvHeadersConfig": "default"
}
'
Python
import requests
url = "https://prod01.oms.fabric.inc/api/v2/exports"
payload = {
"filters": {
"retail": { "locationNum": 12 },
"orderSubTotal": {
"gte": 1300,
"lt": 1400
},
"orderNumber": "order-*Z",
"statusCode": ["ORDER_CREATED"],
"createdAt": { "lt": "2022-09-11T23:12:00.123Z" },
"shipInfo": { "shipToId": ["23434", "23436"] }
},
"module": "ORDER",
"limit": 10,
"offset": 0,
"sortBy": "updatedAt",
"sortDirection": "desc",
"csvHeadersConfig": "default"
}
headers = {
"x-site-context": "<x-site-context>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
JavaScript (Fetch)
const options = {
method: 'POST',
headers: {
'x-site-context': '<x-site-context>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
filters: {
retail: {locationNum: 12},
orderSubTotal: {gte: 1300, lt: 1400},
orderNumber: 'order-*Z',
statusCode: ['ORDER_CREATED'],
createdAt: {lt: '2022-09-11T23:12:00.123Z'},
shipInfo: {shipToId: ['23434', '23436']}
},
module: 'ORDER',
limit: 10,
offset: 0,
sortBy: 'updatedAt',
sortDirection: 'desc',
csvHeadersConfig: 'default'
})
};
fetch('https://prod01.oms.fabric.inc/api/v2/exports', 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://prod01.oms.fabric.inc/api/v2/exports",
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([
'filters' => [
'retail' => [ 'locationNum' => 12 ],
'orderSubTotal' => [ 'gte' => 1300, 'lt' => 1400 ],
'orderNumber' => 'order-*Z',
'statusCode' => [ 'ORDER_CREATED' ],
'createdAt' => [ 'lt' => '2022-09-11T23:12:00.123Z' ],
'shipInfo' => [ 'shipToId' => [ '23434', '23436' ] ]
],
'module' => 'ORDER',
'limit' => 10,
'offset' => 0,
'sortBy' => 'updatedAt',
'sortDirection' => 'desc',
'csvHeadersConfig' => 'default'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-site-context: <x-site-context>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
API Response Examples
200 OK
{
"module": "order",
"keyId": "6213c2d4deeadd00debb46b4",
"version": 123,
"status": "FINISHED",
"totalRowsExported": 20,
"totalRecordsExported": 20,
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"filters": {
"orderSubTotal": {
"gte": 1300,
"lt": 1400
},
"orderNumber": "order-*Z",
"statusCode": [ "ORDER_CREATED" ],
"createdAt": {"lt": "2022-09-11T23:12:00.123Z"}
}
}
Error Responses
{
"message": "[module must not be null]"
}
{
"message": "Not Found"
}
{
"message": "Internal Server Error"
}