Loading...
Area: Optimizely Service API
Applies to versions: 1 and higher

Bulk operations

Recommended reading 

This section describes how to work with bulk operations when using the Optimizely Service API, a service layer used for integration of Optimizely Commerce with external systems, such as PIM, DAM and ERPs.

How it works

Integrations with for example PIM systems often involve 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

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; }
  }
Note: Only consider a task completed if the message type is number 4 or 5.

Get task status

This method gets the last status message of the associated task identifier.

get/episerverapi/commerce/task/{taskId}/status

JSON response type

C# code sample

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

Get task log

This method gets the aggregated status messages of the associated task identifier.

get/episerverapi/commerce/task/{taskId}/log

JSON response type

C# code sample

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

Related topics

Do you find this information helpful? Please log in to provide feedback.

Last updated: Oct 20, 2016

Recommended reading