I’m trying to upload files thru API. Here’s the test:
Verify Updating Property Media and Text
[Tags]
## Add Property Media & Text
${id} Get File ${CURDIR}\resources\sales_property_id.txt
${params} Create Dictionary text=
test
${response} Put On Session auto_test api/crm-lifecycle/short-description/${id} json=${params}
Status Should Be OK ${response}
## Add Full Description
${response} Put On Session auto_test api/crm-lifecycle/full-description/${id} json=${params}
Status Should Be OK ${response}
# Add Property Image
${file} Get File For Streaming Upload ${CURDIR}\resources\kitchen_dining_img.jpg
${response} Post On Session auto_test api/crm-lifecycle/${id}/media/1 data=${file}
you are trying to upload a file with content-type application/json and your backend responds with: Incorrect Content-Type: application/json
POST On Session keyword document refers:
Other optional requests arguments can be passed using **kwargs see the GET keyword for the complete list.
On the GET section;
Other optional requests arguments can be passed using **kwargs here is a list:
On files row:
Dictionary of file-like-objects (or {'name': file-tuple}) for multipart encoding upload. file-tuple can be a 2-tuple ('filename', fileobj), 3-tuple ('filename', fileobj, 'content_type') or a 4-tuple ('filename', fileobj, 'content_type', custom_headers), where 'content-type' is a string defining the content type of the given file and custom_headers a dict-like object containing additional headers to add for the file.
Instead of passing data, fix might be to use files with the 3-tuple filename, fileobj and content-type ?