Get export jobs by query - Fabric

Get export jobs by query

cURL

curl --request POST \
  --url 'https://api.fabric.inc/v3/oms-exports/search?limit=10' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'x-fabric-channel-id: <x-fabric-channel-id>' \
  --header 'x-fabric-tenant-id: <x-fabric-tenant-id>' \
  --data '\n{\n  "filters": [\\n    {\\n      "condition": "EQ",\\n      "field": "export.module",\\n      "value": "Order"\\n    },\\n    {\\n      "condition": "IN",\\n      "field": "export.status",\\n      "values": [\\n        "FINISHED",\\n        "PROCESSING"\\n      ]\\n    }\\n  ],\n  "sort": "-export.createdAt"\n}\n'

Python

import requests

url = "https://api.fabric.inc/v3/oms-exports/search?limit=10"

payload = {
    "filters": [\
        {\
            "condition": "EQ",\
            "field": "export.module",\
            "value": "Order"\
        },\
        {\
            "condition": "IN",\
            "field": "export.status",\
            "values": ["FINISHED", "PROCESSING"]\
        }\
    ],
    "sort": "-export.createdAt"
}
headers = {
    "x-fabric-tenant-id": "<x-fabric-tenant-id>",
    "x-fabric-channel-id": "<x-fabric-channel-id>",
    "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-fabric-tenant-id': '<x-fabric-tenant-id>',
    'x-fabric-channel-id': '<x-fabric-channel-id>',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    filters: [\
      {condition: 'EQ', field: 'export.module', value: 'Order'},\
      {condition: 'IN', field: 'export.status', values: ['FINISHED', 'PROCESSING']}\
    ],
    sort: '-export.createdAt'
  })
};

fetch('https://api.fabric.inc/v3/oms-exports/search?limit=10', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

PHP

<?php

$curl = curl_init();

curl_setopt_array($curl, [\
  CURLOPT_URL => "https://api.fabric.inc/v3/oms-exports/search?limit=10",\
  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' => [\
        [\
                'condition' => 'EQ',\
                'field' => 'export.module',\
                'value' => 'Order'\
        ],\
        [\
                'condition' => 'IN',\
                'field' => 'export.status',\
                'values' => [\
                                'FINISHED',\
                                'PROCESSING'\
                ]\
        ]\
    ],\
    'sort' => '-export.createdAt'\
  ]),\
  CURLOPT_HTTPHEADER => [\
    "Authorization: Bearer <token>",\
    "Content-Type: application/json",\
    "x-fabric-channel-id: <x-fabric-channel-id>",\
    "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;
}
?>

Response

Successful Response

{
  "data": [\
    {\
      "module": "ORDER",\
      "recordFormat": "CSV",\
      "version": 2,\
      "createdAt": "2022-11-22T10:26:38Z",\
      "csvHeadersConfig": "default",\
      "exportId": "order_2022-11-25T17-25-38-417225543Z",\
      "status": "INITIATED",\
      "totalRecordsExported": 20,\
      "totalRowsExported": 20,\
      "updatedAt": "2022-11-22T10:26:38Z",\
      "url": "https://abc.zip"\
    }\
  ],\
  "pagination": {\
    "count": 1000,\
    "limit": 10,\
    "offset": 1\
  },\
  "stats": [\
    "<string>"\
  ]
}

Error Responses

{
  "errors": [\
    {\
      "message": "Invalid request",\
      "type": "CLIENT_ERROR"\
    }\
  ],\
  "message": "Bad request",
  "type": "CLIENT_ERROR"
}
{
  "message": "Unauthorized request",
  "type": "CLIENT_ERROR"
}
{
  "message": "Internal server error",
  "type": "SERVER_ERROR"
}