Import Catalog Info

Updated 3 weeks ago ​by nussi

Overview

Whenever you need to import catalog info, you will have a host of options that are designed to simplify the whole process.

  • Import Catalog Info via the new SellerCloud UI that allows us to import different kind of catalog metadata
  • Import Catalog Info via REST API allows us to do same kind of operations.

Import Catalog Info via SellerCloud UI

Import Catalog Info via REST API

REST API support 6 different import types:

  • Bulk Update Products
  • Variations
  • Shadows
  • Kits
  • Product Images
  • Variation Images

In order to do import of some catalog info, you should first download a dummy template and populate with the information that will be imported. Downloading a template can happen from SellerCloud UI and from REST API as well.

Bulk Update Products

In order to do bulk update, you have to first download a dummy template from SellerCloud UI in one of the formats:

  • TAB Delimited
  • CSV
  • Excel

You can not only choose the file format, but also the columns that you want to use. In the following video we show how you can define your own custom template. Later it can be used for importing different kind of product info in bulk via the REST API.

After template is downloaded and filled with catalog info either manually or via code, now we can proceed to using that template for real bulk import from REST API.

Endpoint for bulk update for TT server is:

https://tt.api.sellercloud.com/api/Catalog/Imports/Custom

Endpoint for another server will be:

https://{server_id}.api.sellercloud.com/api/Catalog/Imports/Custom

Information about the endpoint can be found in Swagger as well:

  • Method Type: HttpPost
  • Authorization: Use Bearer Token + token received from token authentication
  • Header Info: Content-Type: application/json
  • Body with information for the updated products in bulk

Parameter

Data Type

Description

Is Required

Format

int

Format of the file that holds information for updated products. Mandatory.

Tab Delimited = 0

CSV = 1

Excel = 2

Yes

FileContents

string

Content of the file in binary format and Base 64 encoded. Mandatory.

Yes

Metadata

object

Hold information about how to proceed with the new products, schedule task information etc. Mandatory

Format:

"Metadata": {

"ScheduleDate": "",

"CreateProductIfDoesntExist": true,

"CompanyIdForNewProduct": 1,

"UpdateFromCompanyId": 0

},

ScheduleDate: At what time task to be scheduled. Not Mandatory.

CreateProductIfDoesntExist: Boolean.Indicate if new products should be added in SellerCloud if does not exist or only update existing once. Not mandatory. If not set, not found products will not be created in SellerCloud.

CompanyIdForNewProduct: Integer. ID of company. New products from the file import will be linked to that company.

UpdateFromCompanyId: Integer. ID of company.

DoNotUpdateExistingProducts: Boolean. Indicates if found products to be updated. Not mandatory. If not set, found products will be updated.

Yes

Important!

Keep in mind that if you are going to import in bulk some new products, some metadata is required and you need to provide it in the template:

  • If client setting "Require SiteCost and Buyer/Purchaser while creating product" is enabled, then site cost and purchaser are required for the new product.
  • If client setting "Require Manufacturer when creating Product." is enabled, then manufacturer must be provided for the new product.

Response

  • If user is authenticated and provides a valid information in the request, then response will be Status Code 200 => OK and a link to the newly generated queued job.
  • If user is not authenticated, then response will be Status Code 401 => Unauthorized
  • On server error => Status Code 500 => Internal Server Error

Example Response

{
"QueuedJobLink": "Your bulk update has been queued. <a href='/queued-jobs/queued-job-details.aspx?id=28163'>Job # 28163. Click here To monitor Schedule</a>"
}

Example Demo in C#

public enum FileFormatType
{
TAB_Delimited = 0,
CSV = 1,
Excel = 2
}

public class BulkUpdateMetadata
{
public DateTime? ScheduleDate { get; set; }

public bool CreateProductIfDoesntExist { get; set; }

public int CompanyIdForNewProduct { get; set; }

public int UpdateFromCompanyId { get; set; }

public bool DoNotUpdateProducts { get; set; }
}

public class Request
{
public BulkUpdateMetadata Metadata { get; set; }

public string FileContents { get; set; }

public FileFormatType Format { get; set; }
}

string url = $"http://cwa.api.sellercloud.com/api/Catalog/Imports/Custom";
string token = "test_token";

var content = new BulkUpdateProductRequest()
{
FileContents = Convert.ToBase64String(File.ReadAllBytes($@"C:\\Data\\TestRuns\\Bulk.xls")),
Format = FileFormatType.Excel,
Metadata = new BulkUpdateMetadata()
{
CompanyIdForNewProduct = 1
}
};

using (var client = new HttpClient())
using (var request = new HttpRequestMessage(HttpMethod.Post, url))
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);

var json = JsonConvert.SerializeObject(content);
using (var stringContent = new StringContent(json, Encoding.UTF8, "application/json"))
{
request.Content = stringContent;

await client.SendAsync(request);
}
}

Variations Import

Downloading a template for importing variations can happen from Sellercloud UI and from REST API.

Endpoint For Downloading Variations Template

Example for such endpoint for TT server is https://tt.api.sellercloud.com/rest/api/Catalog/Imports/Variations/Template?fileFormat=2

For your server endpoint will be:

https://{server_id}.api.sellercloud.com/rest/api/Catalog/Imports/Variations/Template?fileFormat=2

Request for Downloading Variations Template

enum FileFormatType
{
TAB_Delimited = 0
CSV = 1
Excel = 2
}

Response for downloading variations template

  • If user is authenticated then response will be Status Code 200 => OK

Content of the response will be Base-64 encoded array of bytes, that represent the file content. Client needs to decode and use the bytes array.

Name of the file can be found in the response content header Content-Disposition.

  • If user is not authenticated, then response will be Status Code 401 => Not Valid Token
  • On server response => Status Code 500 => Internal Server Error

Demo in c# for downloading variations template

static async Task DownloadingVariationTemplate()
{
string token = "test_token";
string url = $"localhost:8080/api/Catalog/Imports/Variations/Template?fileFormat=2";

using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", token);
HttpResponseMessage responseMessage = await client.GetAsync(url);

var content = responseMessage.Content
.ReadAsStringAsync()
.Result;
var contentInBytes = Convert.FromBase64String(content);

System.IO.File.WriteAllBytes($@"C:\\Data\\TestRuns\\{responseMessage.Content.Headers.ContentDisposition.FileName}", contentInBytes);
}
}

Request for importing variations

Endpoint for importing variations is:

https://{server_id}.api.sellercloud.com/rest/api/Catalog/Imports/Variations

Shadows Import

Downloading a template that will be used for importing shadows can be done from SellerCloud UI and from REST API.

Endpoint for downloading shadows template

Example for such endpoint for TT server is https://tt.api.sellercloud.com/rest/api/Catalog/Imports/Shadows/Template?fileFormat=2

For your server endpoint will be:

https://{server_id}.api.sellercloud.com/rest/api/Catalog/Imports/Shadows/Template?fileFormat=2

Request for downloading shadows template

Response from downloading shadows template

  • If user is authenticated then response will be Status Code 200 => OK

Content of the response will be Base-64 encoded array of bytes, that represent the file content. Client needs to decode and use the bytes array.

Name of the file can be found in the response content header Content-Disposition.

  • If user is not authenticated, then response will be Status Code 401 => Not Valid Token
  • On server response => Status Code 500 => Internal Server Error

Demo in c# for downloading shadows template

static async Task DownloadingShadowsTemplate()
{
string token = "test_token";
string url = $"localhost:8080/api/Catalog/Imports/Shadows/Template?fileFormat=2";

using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", token);
HttpResponseMessage responseMessage = await client.GetAsync(url);

var content = responseMessage.Content
.ReadAsStringAsync()
.Result;
var contentInBytes = Convert.FromBase64String(content);

System.IO.File.WriteAllBytes($@"C:\\Data\\TestRuns\\{responseMessage.Content.Headers.ContentDisposition.FileName}", contentInBytes);
}
}

Request for importing shadows

Endpoint for importing shadows is:

https://{server_id}.api.sellercloud.com/rest/api/Catalog/Imports/Shadows

Kits Import

Downloading a template that will be used for importing kits can be done from SellerCloud UI and from REST API.

Endpoint for downloading kit template

Example for such endpoint for TT server is https://tt.api.sellercloud.com/rest/api/Catalog/Imports/Kits/Template?fileFormat=2

For your server endpoint will be:

https://{server_id}.api.sellercloud.com/rest/api/Catalog/Imports/Kits/Template?fileFormat=2

Request for downloading kit template

Response when downloading kits template

  • If user is authenticated then response will be Status Code 200 => OK

Content of the response will be Base-64 encoded array of bytes, that represent the file content. Client needs to decode and use the bytes array.

Name of the file can be found in the response content header Content-Disposition.

  • If user is not authenticated, then response will be Status Code 401 => Not Valid Token
  • On server response => Status Code 500 => Internal Server Error

Request for importing kits

Endpoint for importing kits is:

https://{server_id}.api.sellercloud.com/rest/api/Catalog/Imports/Kits

Product Images Import

Downloading a template that will be used for importing product images can be done from SellerCloud UI and from REST API.

Endpoint for downloading product images template

Endpoint for downloading product images template is:

https://{server_id}.api.sellercloud.com/rest/api/Catalog/Imports/Images/Template

Response when downloading product images template

  • If user is authenticated then response will be Status Code 200 => OK

Content of the response will be Base-64 encoded array of bytes, that represent the file content. Client needs to decode and use the bytes array.

Name of the file can be found in the response content header Content-Disposition.

  • If user is not authenticated, then response will be Status Code 401 => Not Valid Token
  • On server response => Status Code 500 => Internal Server Error

Demo in c# for downloading variations images template

static async Task DownloadingShadowsTemplate()
{
string token = "test_token";
string url = $"localhost:8080/api/Catalog/Imports/Images/Template?fileFormat=2";

using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", token);
HttpResponseMessage responseMessage = await client.GetAsync(url);

var content = responseMessage.Content
.ReadAsStringAsync()
.Result;
var contentInBytes = Convert.FromBase64String(content);

System.IO.File.WriteAllBytes($@"C:\\Data\\TestRuns\\{responseMessage.Content.Headers.ContentDisposition.FileName}", contentInBytes);
}
}

Variations Images Import

Downloading a template that will be used for importing variations images can be done from SellerCloud UI and from REST API.

Endpoint for downloading variations images template

Endpoint for downloading variations images template is:

https://{server_id}.api.sellercloud.com/rest/api/Catalog/Imports/Variations/Images/Template

Response when downloading variations images template

  • If user is authenticated then response will be Status Code 200 => OK

Content of the response will be Base-64 encoded array of bytes, that represent the file content. Client needs to decode and use the bytes array.

Name of the file can be found in the response content header Content-Disposition.

  • If user is not authenticated, then response will be Status Code 401 => Not Valid Token
  • On server response => Status Code 500 => Internal Server Error

Demo in c# for downloading variations images template

static async Task DownloadingShadowsTemplate()
{
string token = "test_token";
string url = $"localhost:8080/api/Catalog/Imports/Variations/Images/Template?fileFormat=2";

using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", token);
HttpResponseMessage responseMessage = await client.GetAsync(url);

var content = responseMessage.Content
.ReadAsStringAsync()
.Result;
var contentInBytes = Convert.FromBase64String(content);

System.IO.File.WriteAllBytes($@"C:\\Data\\TestRuns\\{responseMessage.Content.Headers.ContentDisposition.FileName}", contentInBytes);
}
}

Request for uploading variations images

Endpoint for uploading variations images is:

​https://{server_id}.api.sellercloud.com/api/Catalog/Imports/Variations/Images

Data

Type

Description

Is Required

FileContents

string

Base 64 encoded array of bytes

Yes

Format

int

Format of the file: tab delimited, csv or excel

Yes


How did we do?