---
title: Bulk operations
slug: commerce-connect-15/service-api/working-with-bulk-operations-using-tasks
docTags: 
createdAt: 2026-07-22T14:38:28.000Z
---

Integrations, such as with Optimizely Product Information Management, often involve the transfer of large data volumes. The Service API allows for bulk operations that can take a long time to complete.

To facilitate long-running tasks, bulk operations return a *task identifier* that you can use to get the status of a task and any associated messages. You can get *last* or *aggregated* status messages for the associated task identifier.

## Example model

```csharp
using System;

public enum MessageType
  {
    Progress = 0,
    Debug = 1,
    Info = 2,
    Warning = 3,
    Success = 4,
    Error = 5
  }

public class JobMessage
  {
    public DateTime TimestampUtc { get; set; }
    public MessageType MessageType { get; set; }
    public string Message { get; set; }
    public string StageName { get; set; }
    public int StageIndex { get; set; }
    public int StageCount { get; set; }
    public int StageProgress { get; set; }
    public int StageTotalProgress { get; set; }
    public string ExceptionMessage { get; set; }
    public string ExceptionStackTrace { get; set; }
  }
```

:::hint{type="info"}
**Note**
Only consider a task completed if the message type is number 4 or 5.
:::

### Get task status

| GET | get/episerverapi/commerce/task/`{taskId}`/status | This method gets the \_last\_status message of the associated task identifier. |
| --- | ------------------------------------------------ | ------------------------------------------------------------------------------ |

### JSON response type

C# code sample

```csharp
using (var client = new HttpClient())
  {
    client.BaseAddress = new Uri("https://mysite.com/");
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
    var response = client.GetAsync("/episerverapi/commerce/task/`{taskId}`/status", content).Result;
  }
```

### XML response type

C# code sample

```csharp
using (var client = new HttpClient())
  {
    client.BaseAddress = new Uri("https://mysite.com/");
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/xml"));
    var response = client.GetAsync("/episerverapi/commerce/task/`{taskId}`/status", content).Result;
	
  }
```

Response

```xml
<JobMessage xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <TimestampUtc>2014-09-08T10:18:12.8122808Z</TimestampUtc>
  <MessageType>Success</MessageType>
  <Message>Task complete.</Message>
  <StageName>Import</StageName>
  <StageIndex>1</StageIndex>
  <StageCount>2</StageCount>
  <StageProgress>10000</StageProgress>
  <StageTotalProgress>10000</StageTotalProgress>
</JobMessage>
```

### Get task log

| GET | get/episerverapi/commerce/task/`{taskId}`/log | This method gets the *aggregated* status messages of the associated task identifier. |
| --- | --------------------------------------------- | ------------------------------------------------------------------------------------ |

### JSON response type

C# code sample

```csharp
using (var client = new HttpClient())
  {
    client.BaseAddress = new Uri("https://mysite.com/");
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
    var response = client.GetAsync("/episerverapi/commerce/task/`{taskId}`/log", content).Result;
  }
```

### XML response type

C# code sample

```csharp
using (var client = new HttpClient())
  {
    client.BaseAddress = new Uri("https://mysite.com/");
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("text/xml"));
    var response = client.GetAsync("/episerverapi/commerce/task/`{taskid}`/log", content).Result;
  }
```

Response

```xml
<ArrayOfJobMessage xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <JobMessage>
    <TimestampUtc>2014-09-08T10:18:07.8687819Z</TimestampUtc>
    <MessageType>Info</MessageType>
    <Message>Preparing to unpack zip file.</Message>
    <StageName>Extract</StageName>
    <StageIndex>0</StageIndex>
    <StageCount>2</StageCount>
    <StageProgress>0</StageProgress>
    <StageTotalProgress>1</StageTotalProgress>
  </JobMessage>
   <JobMessage>
    <TimestampUtc>2014-09-08T10:18:12.7592472Z</TimestampUtc>
    <MessageType>Info</MessageType>
    <Message>Imported catalog TestCatalog</Message>
    <StageName>Import</StageName>
    <StageIndex>1</StageIndex>
    <StageCount>2</StageCount>
    <StageProgress>9900</StageProgress>
    <StageTotalProgress>10000</StageTotalProgress>
  </JobMessage>
  <JobMessage>
    <TimestampUtc>2014-09-08T10:18:12.8102795Z</TimestampUtc>
    <MessageType>Info</MessageType>
    <Message>Import successfully finished.</Message>
    <StageName>Import</StageName>
    <StageIndex>1</StageIndex>
    <StageCount>2</StageCount>
    <StageProgress>10000</StageProgress>
    <StageTotalProgress>10000</StageTotalProgress>
  </JobMessage>
  <JobMessage>
    <TimestampUtc>2014-09-08T10:18:12.8122808Z</TimestampUtc>
    <MessageType>Success</MessageType>
    <Message>Task complete.</Message>
    <StageName>Import</StageName>
    <StageIndex>1</StageIndex>
    <StageCount>2</StageCount>
    <StageProgress>10000</StageProgress>
    <StageTotalProgress>10000</StageTotalProgress>
  </JobMessage>
</ArrayOfJobMessage>
```
