System Information
- Strapi Version: 4.1.0
- Operating System:
- Database: sqlite
- Node Version: v14.19.0
- NPM Version: 6.14.16
- Yarn Version: 1.22.17
Hello community!
I’ve gone through the docs without any answer to my problem.
I download an image that is on a bucket and I want to upload it to Strapi via the /upload API.
No problem, it works except that the “alternativeText” property is empty. I want to fill this value.
Following the POST response from the image upload, I got the image ID.
Now I want to update the “alternativeText” property by making a POST request on the route /upload?id=imageId with a payload but it does not work.
I do it in Python.
How do you do it on your side please?
files = {
'files':
(
'image_name',
'path/files' ,
'type_mime'
),
}
headers = {
"accept" : "application/json",
"Authorization" : 'Bearer my_token' ,
}
responseUploadImage= requests.post(
url= 'http://localhost:1337/api/upload',
files=files,
headers=headers
)
content = json.loads(responseUploadImage.content)
imageID= content[0]['id']
payload= json.dumps({
'fileInfo': {"alternativeText":"alt","caption":"caption","name":"iamage_name"}
})
response= requests.post(
url= 'http://localhost:1337/api/upload?id=' + str(imageID),
data=payload,
headers = {
"accept" : "application/json",
"Authorization" : 'Bearer ' + os.environ['API_KEY'],
}
)