Jobs client

The jobs client can be used to create many kinds of fetch jobs in the Sitecore Content Hub.

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.

Create 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:

RequestResponse

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

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

Do you have some feedback for us?

If you have suggestions for improving this article,