POST /work-requests/{id}/tasks
1 min
POST
https://api.cmp.optimizely.com/v3/work-requests/{id}/tasks
Path Parameters
- idstringrequiredExampleDescription
Body Parameters
- bodyWorkRequestTaskRequestrequiredDescription
- titlestringExampleDescription
- start_atstring<date-time>ExampleDescriptionFormatdate-time
- due_atstring<date-time>ExampleDescriptionFormatdate-time
- campaign_idstringExampleDescription
- workflow_idstringExampleDescription
- owner_idstringExampleDescription
- asset_ids_without_field_inheritancestring[]Example
[ "74f12a064b1611eda2fe02420ac8001d" ]
Description - inherit_fields_fromstringExampleDescriptionDefaultwork_request
- exclude_empty_fieldsbooleanExampleDescriptionDefaulttrue
Responses
201
- WorkRequestTaskResponse
- idstringrequiredExampleDescription
- titlestringrequiredExampleDescription
- reference_idstringExampleDescription
- start_atstring<date-time>requiredExampleDescriptionFormatdate-time
- due_atstring<date-time>requiredExampleDescriptionFormatdate-time
- owner_idstringrequiredExampleDescription
- linksobjectrequiredDescription
- selfstringrequiredExampleDescription
- ownerstringExampleDescription
400
- ErrorExample
{ "message": "Unsupported arguments: a,b,c" }Description- messagestringrequiredExampleDescription
- errorsmap<string, string>Description
401
- ErrorExample
{ "message": "Unauthorized" }Description- messagestringrequiredExampleDescription
- errorsmap<string, string>Description
403
- ErrorExample
{ "message": "You do not have the permission to perform this operation" }Description- messagestringrequiredExampleDescription
- errorsmap<string, string>Description
404
- ErrorExample
{ "message": "Resource not found" }Description- messagestringrequiredExampleDescription
- errorsmap<string, string>Description
422
- ErrorExample
{ "message": "Resource cannot be processed" }Description- messagestringrequiredExampleDescription
- errorsmap<string, string>Description
curl
curl --request POST \
--url https://api.cmp.optimizely.com/v3/work-requests/{id}/tasks \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '{
"inherit_fields_from": "work_request",
"exclude_empty_fields": true
}'javascript
var myHeaders = new Headers();
myHeaders.append("accept", "application/json");
myHeaders.append("content-type", "application/json");
var raw = JSON.stringify({
"inherit_fields_from": "work_request",
"exclude_empty_fields": true
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.cmp.optimizely.com/v3/work-requests/{id}/tasks", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));ruby
require "uri"
require "json"
require "net/http"
url = URI("https://api.cmp.optimizely.com/v3/work-requests/{id}/tasks")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["accept"] = "application/json"
request["content-type"] = "application/json"
request.body = JSON.dump({
"inherit_fields_from": "work_request",
"exclude_empty_fields": true
})
response = https.request(request)
puts response.read_body
python
import requests
import json
url = "https://api.cmp.optimizely.com/v3/work-requests/{id}/tasks"
payload = json.dumps({
"inherit_fields_from": "work_request",
"exclude_empty_fields": True
})
headers = {
'accept': 'application/json',
'content-type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
201
// Created a task from a work request
{
"id": "8q7f910551b00a722e0418830cee6612",
"title": "The awesome task",
"reference_id": "TSK-1111",
"start_at": "2022-12-01T06:00:00Z",
"due_at": "2022-12-31T06:00:00Z",
"owner_id": "8q7f910551b00a722e0418830cee6612",
"links": {
"self": "https://api.cmp.optimizely.com/v3/tasks/8q7f910551b00a722e0418830cee6612",
"owner": "https://api.cmp.optimizely.com/v3/users/8q7f910551b00a722e0418830cee6612"
}
}400
// Client error
{
"message": "Not found",
"errors": ""
}401
// Authorization error
{
"message": "Not found",
"errors": ""
}403
// Permission error
{
"message": "Not found",
"errors": ""
}404
// Not found error
{
"message": "Not found",
"errors": ""
}422
// Unprocessable entity error
{
"message": "Not found",
"errors": ""
}