Update Element
Update element with specified id.
patch
https://environment.lvis.io
/api/v2/elements/:element_id
Update Element
Update attributes possible only for non-published elements.
Request
Response
cURL
// PATCH /api/v2/elements/85ce5d32-a6b4-4219-bc72-4fcf18f2a5dc
// Host: environment.monterosa.cloud
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json
{
"data": {
"id": "85ce5d32-a6b4-4219-bc72-4fcf18f2a5dc",
"type": "elements",
"attributes": {
"question": {
"fields": [
{
"key": "text",
"values": {
"en": "Another Question Text"
}
}
],
"options": [
{
"fields": [
{
"key": "text",
"values": {
"en": "Another Option Text #1"
}
}
]
},
{
"fields": [
{
"key": "text",
"values": {
"en": "Another Option Text #2"
}
}
]
}
]
}
}
}
}
// Status: 204 No Content
curl --request PATCH \
--url https://environment.monterosa.cloud/api/v2/elements/85ce5d32-a6b4-4219-bc72-4fcf18f2a5dc \
--header 'Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb' \
--header 'Content-Type: application/vnd.api+json' \
--data '{
"data": {
"id": "85ce5d32-a6b4-4219-bc72-4fcf18f2a5dc",
"type": "elements",
"attributes": {
"question": {
"fields": [
{
"key": "text",
"values": {
"en": "Another Question Text"
}
}
],
"options": [
{
"fields": [
{
"key": "text",
"values": {
"en": "Another Option Text #1"
}
}
]
},
{
"fields": [
{
"key": "text",
"values": {
"en": "Another Option Text #2"
}
}
]
}
]
}
}
}
}'
In current example we change the question and options texts.
Element can be published for the active event only.
Element published via passing "publish" for action attribute.
Request
Response
cURL
// PATCH /api/v2/elements/37e27fe2-845a-4574-92ad-ff97f44edcba
// Host: environment.monterosa.cloud
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json
{
"data": {
"id": "37e27fe2-845a-4574-92ad-ff97f44edcba",
"type": "elements",
"attributes": {
"action": "publish"
}
}
}
// Status: 204 No Content
curl --request PATCH \
--url https://environment.monterosa.cloud/api/v2/elements/85ce5d32-a6b4-4219-bc72-4fcf18f2a5dc \
--header 'Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb' \
--header 'Content-Type: application/vnd.api+json' \
--data '{
"data": {
"id": "37e27fe2-845a-4574-92ad-ff97f44edcba",
"type": "elements",
"attributes": {
"action": "publish"
}
}
}'
Reveal an answer for elements with manual reveal answer mode is possible via passing "reveal_answer" like the "action" attribute.
Request
Response
cURL
// PATCH /api/v2/elements/37e27fe2-845a-4574-92ad-ff97f44edcba
// Host: environment.monterosa.cloud
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json
{
"data": {
"id": "37e27fe2-845a-4574-92ad-ff97f44edcba",
"type": "elements",
"attributes": {
"action": "reveal_answer",
"correct_option": 1
}
}
}
// Status: 204 No Content
curl --request PATCH \
--url https://environment.monterosa.cloud/api/v2/elements/85ce5d32-a6b4-4219-bc72-4fcf18f2a5dc \
--header 'Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb' \
--header 'Content-Type: application/vnd.api+json' \
--data '{
"data": {
"id": "37e27fe2-845a-4574-92ad-ff97f44edcba",
"type": "elements",
"attributes": {
"action": "reveal_answer",
"correct_option": 1
}
}
}'
When we are trying to update a field that doesn't exist in the element spec.
Request
Response
// PATCH /api/v2/elements/00b32a9c-ee68-4744-82d7-1812e80a14bb
// Host: environment.monterosa.cloud
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json
{
"data": {
"id": "00b32a9c-ee68-4744-82d7-1812e80a14bb",
"type": "elements",
"attributes": {
"custom_fields": [
{
"key": "INVALID_text",
"values": {
"en": "New Text 2"
}
}
]
}
}
}
// Status: 422 Unprocessable Entity
{
"errors": [
{
"source": {
"pointer": "/data/attributes/custom_fields/0/key"
},
"detail": "field must be specified in the settings spec"
}
]
}
Last modified 18d ago