You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an endpoint roughly defined as follows in my swagger spec, which I'm using the RequestsClient to intercat with underneath:
/resource/{resourceID}:
patch:
tags:
- my-tagsummary: Updates resourcedescription: 'Updates an existing resource by ID'operationId: updateResourceconsumes:
- multipart/form-dataproduces:
- application/jsonparameters:
- in: pathname: resourceIDrequired: truetype: stringdescription: The ID of the resource to update
- in: formDataname: resourceConfigFiletype: filerequired: false
- in: formDataname: resourceFootype: stringrequired: falseresponses:
'204':
description: Update successful'400':
description: Bad requestschema:
$ref: '#/definitions/ErrorResponse''404':
description: kube client info not foundschema:
$ref: '#/definitions/ErrorResponse''500':
description: Internal / unexpected errorschema:
$ref: '#/definitions/ErrorResponse'
When I send a request to it without any of the required parameters, I get an error back from my server claiming that the Content-Type header is wrong. This is entirely correct as there's no content-type set at all:
If I sent a request with the non-file optional parameter, I get a 415 unsupported media error back. This time it's because the content-type was set to application/x-www-form-urlencoded, where the request looks like this:
Finally, if I actually send the file, the correct Content-Type is set and everything works as expected. In trying to workaround this, I tried to set the content type by hand and then went down the rabbit hole learning about setting the boundary and related things. In general, the advice seems to be to let the browser or underlying library do it for you.
At the moment, I can't tell if this is a bug in bravado, or something lower down. Reading over this suggests the correct thing to do if multipart/form-data is specified is to always use the files=... parameter when using requests.
The text was updated successfully, but these errors were encountered:
I have an endpoint roughly defined as follows in my swagger spec, which I'm using the RequestsClient to intercat with underneath:
When I send a request to it without any of the required parameters, I get an error back from my server claiming that the Content-Type header is wrong. This is entirely correct as there's no content-type set at all:
If I sent a request with the non-file optional parameter, I get a 415 unsupported media error back. This time it's because the content-type was set to application/x-www-form-urlencoded, where the request looks like this:
Finally, if I actually send the file, the correct Content-Type is set and everything works as expected. In trying to workaround this, I tried to set the content type by hand and then went down the rabbit hole learning about setting the boundary and related things. In general, the advice seems to be to let the browser or underlying library do it for you.
At the moment, I can't tell if this is a bug in bravado, or something lower down. Reading over this suggests the correct thing to do if multipart/form-data is specified is to always use the
files=...
parameter when using requests.The text was updated successfully, but these errors were encountered: