Updating content through the API
There are two ways to update the content of an object:
PUT
: When updating the object (PUT
requests), all properties must be present in the request body, as the object data are replaced with the request body. The id property inside the object is ignored in PUT requests. Validation of update request works the same as in saving requests.
PATCH
: When updating an object (a PATCH
request), it is not necessary to specify all the properties of the object. The id property inside the object is ignored in PATCH
requests. Validating the update request works the same as it does when saving requests.
Note
You will need to use yourApplication Read and write API KEY
to perform this action orUser API KEY
scoped to accept update on the Content Type you wish to update. Read more about API keys and scoped API keys.
Updating Content Objects through the API
For a Content-Type defined according to the create Content Type example, a very simple PUT
the payload can be sent to the supporting endpoint https://api.flotiq.com/api/v1/content/{name}/{id}
to update Content Object:
"title": "Object with changed title",
"postContent": "This will be the new <b>content</b>"
}
-
name
is the name of the content type definition -
id
is the ID of the object to update
Example
CURL
curl --location --request PUT 'https://api.flotiq.com/api/v1/content/blogposts/blogposts-456712' \
--header 'X-AUTH-TOKEN: YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--header 'Accept: */*' \
--data-raw '{
"title": "Object with changed title",
"postContent": "This will be the new <b>content</b>"
}'
Responses
200 OK
Returned when data has been correct, and the object was saved
"id": "blogposts-456712",
"internal": {
"contentType": "blogposts",
"createdAt": "2021-04-09T13:30:48+00:00",
"updatedAt": "2021-04-09T13:30:48+00:00",
"deletedAt": ""
},
"title": "Object with changed title",
"postContent": "This will be the new <b>content</b>"
}
Possible validation errors
Possible validation errors are the same as in creating Content Object; you can find the list here.
Batch update Content Objects through API
Updating up to 100 objects at once is described here, as batch creating and updating are done on the same API endpoint.
Top comments (0)