contenta_jsonapi
contenta_jsonapi copied to clipboard
Example of making a Recipe Post including image?
Is there an example anywhere of making a POST request for the recipe content type and attaching an image to the entity reference field?
Not an example per se, but the official JSON API documentation (https://www.drupal.org/docs/8/modules/json-api) will explain how to upload files.
@e0ipso Thanks for the reminder about the documentation. I forgot D.O. actually had some good documentation for the JSON API.
One follow up question though, creating a POST request to create an image entity with a base64 image is easy enough, and creating a POST request to create a new node/resource is easy enough.
Are there any "gotchas" or "blockers" for creating a node w paragraph media image entities? Do you know if this is currently possible and has anyone done this yet?
Thanks so much for all your hard work on this!
##POST request with relationships URL: http://example.com/jsonapi/node/article
Request body
{
"data": {
"type": "node--article",
"attributes": {
"title": "Article by admin",
"body": {
"value": "Custom value",
"format": "plain_text"
}
},
"relationships": {
"uid": {
"data": {
"type": "user--user",
"id": "{{UUID of user 1}}"
}
}
}
}
}
source: https://www.drupal.org/docs/8/modules/json-api/creating-new-resources-post
Search for the "Incredible decoupled performance using Subrequests" article in your Contenta knowledge hub.