Reputation: 83527
I am attempting to POST an HTTP request to the Mindee API using IntelliJ IDEA's HTTP client. Specifically, I want to upload an image of a receipt. According to the documentation, the form data must have the form
{ file: your_file }
So my question is...how do I specify the field name for a file in IntelliJ's HTTP client? What is the syntax?
I've tried a few different things with similar results. I get
POST https://api.mindee.net/products/expense_receipts/v3/predict
HTTP/1.1 400 BAD REQUEST
Date: Mon, 01 Feb 2021 22:18:15 GMT
Content-Type: application/json
Content-Length: 84
Connection: keep-alive
Server: nginx/1.15.12
Access-Control-Allow-Origin: *
{
"details": {
"file": [
"This field is required."
]
},
"message": "Invalid fields in form"
}
Here are two of my attempts:
POST https://api.mindee.net/products/expense_receipts/v3/predict
Content-Type: multipart/form-data; bundary=boundary
X-Inferuser-Token: <my token>
{
file: < /path/to/image.jpg
}
POST https://api.mindee.net/products/expense_receipts/v3/predict
Content-Type: multipart/form-data; bundary=boundary
X-Inferuser-Token: <my token>
--boundary
Content-Disposition: form-data; name="file"
< /path/to/image.jpg
--boundary--
The second seemed the most promising since it took longer to return a response, but I still got the same thing.
Upvotes: 2
Views: 3077
Reputation: 3043
The second attempt request should work okay, but you have a typo in there - bundary
instead of boundary
.
Upvotes: 3