Skip to content

Commit 67480bb

Browse files
committed
Added notes about form body
1 parent f7d3984 commit 67480bb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

docs/usage.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,15 @@ When the request executes, RestSharp will try to match any `{placeholder}` with
243243

244244
### Request Body
245245

246-
If this parameter is set, its value will be sent as the body of the request.
246+
RestSharp supports multiple ways to add a request body:
247+
- `AddJsonBody` for JSON payloads
248+
- `AddXmlBody` for XML payloads
249+
- `AddStringBody` for pre-serialized payloads
247250

248251
We recommend using `AddJsonBody` or `AddXmlBody` methods instead of `AddParameter` with type `BodyParameter`. Those methods will set the proper request type and do the serialization work for you.
249252

253+
When you make a `POST`, `PUT` or `PATCH` request and added `GetOrPost` [parameters](#get-or-post), RestSharp will send them as a URL-encoded form request body by default. When a request also has files, it will send a `multipart/form-data` request. You can also instruct RestSharp to send the body as `multipart/form-data` by setting the `AlwaysMultipartFormData` property to `true`.
254+
250255
#### AddStringBody
251256

252257
If you have a pre-serialized payload like a JSON string, you can use `AddStringBody` to add it as a body parameter. You need to specify the content type, so the remote endpoint knows what to do with the request body. For example:

0 commit comments

Comments
 (0)