Hello,
I am trying to add/upload images with products using API. For that, I guess we need to provide the id of the uploaded image in the API body of the product.
So, I installed module file entity(https://www.drupal.org/project/file_entity). I checked this issue for my solution: https://www.drupal.org/project/drupal/issues/2682341
I am using POSTMAN to run this API.
I am using Drupal 9.2.0
The API I am using to upload image:
URL:
{{Domain}}/entity/file?_format=hal_json
Method: POST
Body:
{
"_links": {
"type": {
"href": "{{Domain}}/rest/type/file/image"
}
},
"filename": [
{
"value": "imagename.jpg"
}
],
"filemime": [
{
"value": "image/jpg"
}
],
"data": [
{
"value": "base64encoded image string"
}
]
}
Response:
{
"message": "Could not determine entity type bundle: \"type\" field is missing."
}
Any suggestions?
Comments
Comment #2
Saurabh.123 commentedComment #3
cilefen commentedComment #4
Saurabh.123 commented@cilefen hey, can I also get a solution please, I am stuck in here, need a solution
Comment #5
rsr25694 commented@Saurabh.123, hi you should check first how to pass bundle type through api and respectively check whether file path or alternatively id of image while upload test
Comment #6
Saurabh.123 commented@rsr25694 I have checked 'how to pass bundle type through API but did not get any useful article as there is no API documentation in Drupal, the best(useful) article I have checked is 'https://www.drupal.org/project/drupal/issues/2682341'.
And I am trying to implement from the same. Can you please give any idea?
Comment #7
Ashish Nandankar commentedPlease try the below steps
1. Install File Entity module: https://www.drupal.org/project/file_entity
2. Assign administration role to user which is request services with it's basic auth info.
Comment #8
Saurabh.123 commented@Ashish Nandakar, I am getting the same error after following the same steps.
Comment #10
cilefen commentedI am closing this support request because there have been no recent comments.
The Drupal Core issue queue is not the ideal place for support requests. Consider other sources of support.