How-to Cancel a Job
The job cancel API allows you to cancel a job when the status is Pending or Running. In your job cancel request, use the returned job ID from your Media job.
Check the Job Status
Before you cancel a job, you can check the current job status to make sure it is Pending or Running.
Here is an example GET request using the Transcode API. You will need to replace the job_id with the value returned from your Media API request and update the URL with the Media API that you are using.
import os
import requests
url = "https://api.dolby.com/media/transcode"
headers = {
"x-api-key": os.environ["DOLBYIO_API_KEY"],
"Content-Type": "application/json",
"Accept": "application/json",
}
# TODO: You must replace this value with the job ID returned from your Media API job.
params = {
"job_id": "12345678-d7eb-4012-9b46-0fa5ae6011f3"
}
try:
response = requests.get(url, params=params, headers=headers)
response.raise_for_status()
except requests.exceptions.HTTPError as e:
raise Exception(response.text)
print(response.json())
const axios = require("axios").default
const config = {
method: "get",
url: "https://api.dolby.com/media/transcode",
headers: {
"x-api-key": process.env.DOLBYIO_API_KEY,
"Content-Type": "application/json",
Accept: "application/json",
},
//TODO: You must replace this value with the job ID returned from your Media API job.
params: {
job_id: process.env.DOLBYIO_JOB_ID,
},
}
axios(config)
.then(function(response) {
console.log(JSON.stringify(response.data, null, 4))
})
.catch(function(error) {
console.log(error)
})
#!/bin/bash
curl -X GET "https://api.dolby.com/media/transcode?job_id=$DOLBYIO_JOB_ID" \
--header "x-api-key: $DOLBYIO_API_KEY"
# TODO: You must replace this value with the job ID returned from your Media API job.
Make a Job Cancel Request
To cancel your media job, you use the job ID that was returned when you started your media job.
import os
import requests
# TODO: You must replace this value with the job ID returned from your Media API job.
query = {'job_id': JOB_ID }
response = requests.post("https://api.dolby.com/media/jobs/cancel", params=query,
headers = {
"x-api-key": os.environ["DOLBYIO_API_KEY"],
})
response.raise_for_status()
print(response.json())
const axios = require('axios').default;
const config = {
method: 'post',
url: 'https://api.dolby.com/media/jobs/cancel',
//TODO: You must replace this value with the job ID returned from your Media API job.
params: {
job_id: JOB_ID
},
headers: {
'x-api-key': process.env.DOLBYIO_API_KEY,
}
};
axios(config)
.then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.log(error);
});
% curl -X POST "https://api.dolby.com/media/jobs/cancel?job_id=:job_id" \
--header "x-api-key: $DOLBYIO_API_KEY"
# TODO: You must replace this value with the job ID returned from your Media API job.
Learn More
Updated 3 months ago
Did this page help you?