Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show how to send multipart form data without files #3427

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Form encoded data can also include multiple values from a given key.
}
```

## Sending Multipart File Uploads
## Sending Multipart File Uploads and/or Data

You can also upload files, using HTTP multipart encoding:

Expand Down Expand Up @@ -221,6 +221,23 @@ If you need to include non-file data fields in the multipart form, use the `data
}
```

If you need to send non-file data only, you can do so by using a tuple
of items for the field value without a filename:

```pycon
>>> files = {'some-field': (None, "field-value")}
>>> r = httpx.post("https://httpbin.org/post", files=files)
>>> print(r.text)
{
...
"files": {},
"form": {
"some-field": "field-value"
},
...
}
```

## Sending JSON Encoded Data

Form encoded data is okay if all you need is a simple key-value data structure.
Expand Down