Hello,
I'm trying to upload an image to the server but I keep getting a bad request response.
On Postman, the request's body is set to "form-data" with 2 fields, ID and the file to upload. Also, the request has a bearer token in its header. The request works properly there.

I've tried using HttpRequest with a key value body, first value pointing to the string id and the second pointing to an Image. I tried also passing image.data["data"] or passing Marshalls base64.
var body = {
"id": _id,
"file": image
}
I've also tried HttpClient with a PoolByteArray as follows:
var headers = [
"Authorization : Bearer %s" % Token,
"Content-Length: " + str(content.size()),
"Content-Type: multipart/form-data, boundary=------WebKitFormBoundary7MA4YWxkTrZu0gW"
]
var body = PoolByteArray()
body.append("------WebKitFormBoundary7MA4YWxkTrZu0gW\n")
body.append("Content-Disposition: form-data; name=\"file\"; filename=\"Treasure.png\"\n")
body.append("Content-Type: image/png\n\n")
body.append_array(content)
body.append("\n------WebKitFormBoundary7MA4YWxkTrZu0gW\n")
body.append("Content-Disposition: form-data; name=\"id\"\n\n")
body.append(str(_id))
body.append("\n------WebKitFormBoundary7MA4YWxkTrZu0gW")
I'm sure I'm doing something wrong but I haven't really found an example to upload a file while having another parameter to pass.
Any help or guidance?
Thanks in advance!