## Retrieve jobs

### cURL

```bash
curl --request GET \
  --url 'https://api.fabric.inc/v3/catalog-connector-jobs?limit=10' \
  --header 'Authorization: Bearer <token>' \
  --header 'x-fabric-tenant-id: <x-fabric-tenant-id>'
```

### Python

```python
import requests

url = "https://api.fabric.inc/v3/catalog-connector-jobs?limit=10"

headers = {
    "x-fabric-tenant-id": "<x-fabric-tenant-id>",
    "Authorization": "Bearer <token>"
}

response = requests.get(url, headers=headers)

print(response.text)
```

### JavaScript (Fetch)

```javascript
const options = {
  method: 'GET',
  headers: {'x-fabric-tenant-id': '<x-fabric-tenant-id>', Authorization: 'Bearer <token>'}
};

fetch('https://api.fabric.inc/v3/catalog-connector-jobs?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/catalog-connector-jobs?limit=10",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "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

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

url := "https://api.fabric.inc/v3/catalog-connector-jobs?limit=10"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("x-fabric-tenant-id", "<x-fabric-tenant-id>")
	req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))
}
```

### Unirest (Java)

```java
HttpResponse<String> response = Unirest.get("https://api.fabric.inc/v3/catalog-connector-jobs?limit=10")
  .header("x-fabric-tenant-id", "<x-fabric-tenant-id>")
  .header("Authorization", "Bearer <token>")
  .asString();
```

### Ruby

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.fabric.inc/v3/catalog-connector-jobs?limit=10")

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

request = Net::HTTP::Get.new(url)
request["x-fabric-tenant-id"] = '<x-fabric-tenant-id>'
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
```

### Response Formats

#### Success Response (200)
```json
{
  "data": [
    {
      "id": "877f1f77bcf86cd799439087",
      "inputFileId": "327f1f77bcf86cd799439045",
      "outputFiles": [
        "507f1f77bcf86cd7994390163, 967f1f77bcf86cd799439058"
      ],
      "errorFiles": [
        "887f1f77bcf86cd799439011, 997f1f77bcf86cd799439074"
      ],
      "progressTracker": {
        "updatedAt": "2023-02-14T22:10:30.618Z",
        "totalCount": 100000,
        "processedCount": 40000,
        "errorCount": 10
      },
      "status": "COMPLETED",
      "statusMessage": "100% completed",
      "additionalDetails": {
        "itemsCreated": 10,
        "itemsUpdated": 10
      },
      "createdAt": "2021-09-14T22:10:30.618Z",
      "completedAt": "2021-09-14T22:10:30.618Z",
      "updatedBy": "test@email.com",
      "updatedAt": "2021-09-14T22:10:30.618Z",
      "type": "CATALOG_CONN_ITEM_VARIANT_IMPORT"
    }
  ],
  "offset": 5,
  "limit": 10,
  "count": 100
}
```

#### Error Responses

- **Bad Request (400)**
  ```json
  {
    "message": "Request is invalid",
    "type": "Bad request",
    "errors": [
      {
        "type": "CLIENT_ERROR",
        "message": "Invalid request. Unable to find/create product"
      }
    ]
  }
  ```

- **Unauthorized (401)**
  ```json
  {
    "type": "UNAUTHORIZED_ERROR",
    "message": "Requester is unauthorized"
  }
  ```

- **Permission Denied (403)**
  ```json
  {
    "type": "REQUEST_DENIED",
    "message": "User does not have the required permission"
  }
  ```

- **Server Error (500)**
  ```json
  {
    "type": "SERVER_ERROR",
    "message": "Internal Server Error"
  }
  ```

### Authorization
- **Authorization**: string, header, required
- **x-fabric-tenant-id**: string, required

### Query Parameters

- **ids**: string, limit to 15 IDs.
- **type**: enum, specify job type.
  - Options: `CATALOG_CONN_ITEM_VARIANT_IMPORT`, `CATALOG_CONN_ITEM_VARIANT_EXPORT`, `CATALOG_CONN_BUNDLE_IMPORT`, `CATALOG_CONN_BUNDLE_EXPORT`
- **inputFileIds**: string, limit to 15 IDs.
- **lastJobOnly**: boolean
- **offset**: integer, default 0.
- **limit**: integer, default 10.

### Response
- **200**: application/json, details of the job.
- **data**: object[],
