logo
logo

Jobs client

The SDK provides a Jobs client to create different kinds of fetch jobs in Sitecore Content Hub.

Note

The client variable in the following code examples refers to the IMClient instance. When using the Web SDK, the variable name can be chosen freely, but it is also called client at instantiation in the documentation.

Available fetch jobs

The fetch job models are located in: Stylelabs.M.Sdk.Models.Jobs.

The available models are:

  • AzureFetchJobRequest: a fetch job that fetches one or more files from Azure blob storage.
  • FileFetchJobRequest: a fetch job that fetches one or more files from a directory on the web-server.
  • WebFetchJobRequest: a fetch job that fetches one or more files over HTTP or HTTPS.

When creating a fetch job, the following arguments are always required:

  • Description: a description of the job.
  • Asset id: the asset to link the fetched files on.

Creating a fetch job

To create a fetch job, simply pass the fetch job model to the CreateFetchJobAsync method of the jobs client. This will return the id of the newly created job.

The following example will fetch an image from a public URL and link it to an Asset with id 1000:

var webFetchJob = new WebFetchJobRequest("Fetches an example image from the web.", 1000)
{
        Urls = new[] { new Uri("https://picsum.photos/200") }
};

long jobId = await MClient.Jobs.CreateFetchJobAsync(webFetchJob);

Can we improve this article ? Provide feedback