2

I am trying to access an endpoint that is expecting multipart-form data:

{
  "budget_id": 0,
  "file": "string"
}

with parameter content type application/json.

I can access this endpoint via Postman, choosing a file that is JSON.

However when I have a JSON string in memory and I try to submit an httpx post request, I'm not sure how to encode my string.

I am sending an httpx post with:

data = {'budget-id': 9, 'file' = json_string.encode()}.

and I receive:

The submitted data was not a file.  Check the encoding type on the form.  

Do I need to encode my json_string some other way? I think if I wrote it out to a file and then opened the file I could get this to work, but it seems odd I would have to do that.

martineau
  • 119,623
  • 25
  • 170
  • 301
Ruth Smith
  • 41
  • 3

0 Answers0