How do I update file in a model in strapi via API?

  1. I query the product like this:
    https://api.com/api/products/548/

The response shows up, without all the fields I dont get the thumb field, but when I query like this:- https://api.com/api/products?populate=*&[filters][id][$eq]=386 I get the whole data along with the “thumb field”

  1. When I try to put the “thumb” field which is an image field

Internal server error, https://api.com/api/products/548/ : PUT Request image uploaded in form data.

  1. Image upload works in admin

This topic has been created from a Discord post (1216996038167105606) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

Server error:- Error: Error while uploading asset medium_12_led_interactive_dance_floor_d054ee319c.png Error: Error uploading to cloudinary: Request Timeout

But this error isnt there when uploading via admin

<@1072591948499664996>

I query the product like this:
https://api.com/api/products/548/

The response shows up, without all the fields I dont get the thumb field, but when I query like this:- https://api.com/api/products?populate=*&[filters][id][$eq]=386 I get the whole data along with the “thumb field”

When I try to put the “thumb” field which is an image field

Internal server error, https://api.com/api/products/548/ : PUT Request image uploaded in form data.

Image upload works in admin

Server error:- Error: Error while uploading asset medium_12_led_interactive_dance_floor_d054ee319c.png Error: Error uploading to cloudinary: Request Timeout
But this error isnt there when uploading via admin

Let me check the knowledge base for you. One moment! :books:


Based on the information provided in the extracts, it seems like you’re encountering a couple of issues with Strapi’s image handling and API querying.

  1. Missing “thumb” field in API response: In Strapi, if you want to include relations in your API response, you need to use the populate parameter in your API request. This is why you’re seeing the “thumb” field when you use ?populate=* in your API request. If you want to include this field in all responses without having to use the populate parameter, you might need to customize your API response. However, the extracts don’t provide enough information on how to do this.

  2. Error when uploading image via API: The error message you’re seeing suggests that there’s an issue with uploading images to Cloudinary. This could be due to a variety of reasons, such as network issues, incorrect configuration, or issues with the image file itself.

    In Github Issue 10825 (https://github.com/strapi/strapi/issues/10825), a similar error was reported and it was suggested to double-check the Cloudinary configuration in Strapi. Make sure that your cloud_name, api_key, and api_secret are correct. Also, ensure that your Cloudinary account has the necessary permissions and storage space to upload new images.

    If the issue persists, you might want to look into more detailed logging of the upload process or reach out to Cloudinary’s support for assistance.

Remember, these are just suggestions based on the information provided in the extracts. For more detailed help, you might want to refer to Strapi’s official documentation or community forums.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

<@1072591948499664996> but it works in admin and not the api?

Let me check the knowledge base for you. One moment! :books:


The issue you’re experiencing where image upload works in the Strapi admin panel but not through the API could be due to a variety of reasons. Here are a few possibilities based on the information provided in the extracts:

  1. Different upload mechanisms: The Strapi admin panel and the API might be using different mechanisms or configurations for image upload. This could potentially lead to situations where image upload works in one but not the other.

  2. Different error handling: The Strapi admin panel might have more robust error handling, allowing it to recover from issues that cause the API to fail.

  3. Different permissions: Depending on your Strapi setup, the admin panel and the API might be running with different permissions. This could potentially lead to situations where the admin panel has the necessary permissions to upload images, but the API does not.

Unfortunately, the extracts do not provide enough information to definitively diagnose or solve your issue. For more detailed help, you might want to refer to Strapi’s official documentation or community forums.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

Please help

what does your request look like?

simple formdata reqeust

please ping while replying

For your user; have you set the correct permissions for the upload plugin?

It’s not allowing me to click select all even though the api token has full access

right - that means that is set already.

but all the access is “unchecked” and I cant select any while creating an api token as well?

From the top - don’t select Full Access - pick Custom

Ohk let me see

Server error even after checking all the options and saving