Job check examples

Examples

Go directly to our postman collection of examples:

Using client libraries

Norce Commerce has client libraries for c#. Read more about them here:

Common calls to Connect API

Job/Get

Job/Get is used to ask Norce Commerce about a certain job to get its information.

After a import request have been sent, you can call Norce Commerce Connect to view status of your job. The basic status to check is StatusId, which translates as:

  • 1 = Initialized
  • 2 = Succeeded
  • 3 = Failed
  • 4 = Validation failed

Examples in Postman

Examples in Client Libraries

Here is a code example using .net client library
Copy
Copied
//Using Storm Client library: https://github.com/StormCommerce/Storm.Connect.Contracts
//Nuget: https://www.nuget.org/packages/Enferno.Services.StormConnect.Contracts/
private static void Main()
{
    var serviceUrl = "https://demo.api-se.norce.tech/commerce/connect/4.0/";
    var applicationId = 0;
    var secretKey = Guid.NewGuid();
 
    // List details for specific job
    var job = ImportMethod(serviceUrl, applicationId, secretKey);
    // ...
    // Recheck specific job to see updated status
    var specificJob = GetJob(serviceUrl, applicationId, secretKey, job.JobId);
 
    // List all jobs
    var allJObs = GetJobs(serviceUrl, applicationId, secretKey);
}
 
public static JobDto GetJob(
    string serviceUrl, int applicationId, Guid secretKey, int jobId)
{
    using (var httpClient = new HttpClient())
    {
        var credentials =
                Encoding.ASCII.GetBytes($"{applicationId}:{secretKey.ToString("D")}");
 
        // Base64Encoded Basic authentication is used
        var credentialsToBase64 = Convert.ToBase64String(credentials);
        httpClient.DefaultRequestHeaders.Authorization = 
                    new AuthenticationHeaderValue("Basic", credentialsToBase64);
 
        var jobResponse = httpClient.GetStringAsync($"{serviceUrl}job/{jobId}").Result;
        return JsonConvert.DeserializeObject<JobDto>(jobResponse);
    }
}
 
public static List<JobDto> GetJobs(
    string serviceUrl, int applicationId, Guid secretKey)
{
    using (var httpClient = new HttpClient())
    {
        var credentials =
                Encoding.ASCII.GetBytes($"{applicationId}:{secretKey.ToString("D")}");
 
        // Base64Encoded Basic authentication is used
        var credentialsToBase64 = Convert.ToBase64String(credentials);
        httpClient.DefaultRequestHeaders.Authorization = 
                    new AuthenticationHeaderValue("Basic", credentialsToBase64);
 
        var allJobsResponse = httpClient.GetStringAsync($"{serviceUrl}job").Result;
        return JsonConvert.DeserializeObject<List<JobDto>>(allJobsResponse);
    }
}

ListJobs

Job/List lists all the jobs run since last log cleanup.

Examples in Postman

RestartJob

Job/Restart re-runs a job from the stored data already in Norce. Used mainly in debug scenarios.

Examples in Postman

Ping

Job/Ping does a system check. Used for checking uptime status of the Norce Commerce Connect service.

Examples in Postman

Suggested further reading