How to upload file and link it to Model?

Is it possible to upload a model together with files in one request instead of giving the id of the uploaded file?

instead of
POST → http://localhost:1337/test-model
{

“displayName”: “hello”,
“someFiles”:“3”

}

something like
POST → http://localhost:1337/test-model
{

“displayName”: “hello”
}

someFiles → is name of uploaded files as key value like in the screenshot

Error

{

"statusCode": 400,

"error": "Bad Request",

"message": "When using multipart/form-data you need to provide your data in a JSON 'data' field."

}

@DMehaffy any idears please?

see: https://strapi.io/documentation/developer-docs/latest/plugins/upload.html#upload-file-during-entry-creation

1 Like

Thank you could you please tell me how can i add more property to that cover object? or how to update that alternativeText entity to another string value? Thanks, please again with postman

Currently it’s not possible while uploading a file at the same time you create an entry. If you need the other options you will have to upload the media first and reference the ID when you create the data entry.

{
“data”: null,
“error”: {
“status”: 400,
“name”: “Error”,
“message”: “invalid JSON, only supports object and array”
}
}
I’m still getting this

1 Like