Closed bpbirch closed 2 years ago
I might be wrong, but isn't there an issue with sending json and files in the same http post? Especially nested json beyond simple string key-value pairs.
@whelks-chance - as far as I understand, when we're sending multipart/form-data, we should be passing our other data as string values. This was an issue I've run into in other SDK bindings, and one that Andrew advised me on. For reference, I was using the httpx docs: https://www.python-httpx.org/quickstart/. particularly:
We were unable to submit multipart-form data, for a few main reasons: 1) in SimbaContract.call_contract_method_with_files, we were automatically converting json_payload to json.dumps(json_payload), converting our inputs to string 2) in SimbaRequest.send(), we were calling headers.update({'content-type': 'application/json'}) for all posts, even those including files, which prevents httpx from creating boundary headers for multipart/form-data requests 3) as 1) references, we actually need to be passing inputs as {"str_key": "str_val"}, rather than '{str_key: str_val}'. adding string_keys_and_vals = {str(key): str(val) for key, val in json_payload.items()} fixes this