Skip to content

Commit d8ec481

Browse files
committed
Added AddObject docs
1 parent 5dba590 commit d8ec481

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

docs/usage.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,30 @@ Content-Disposition: form-data; name="parameterName"
191191
ParameterValue
192192
```
193193

194+
#### AddObject
195+
196+
You can avoid calling `AddParameter` multiple times if you collect all the parameters in an object, and then use `AddObject`.
197+
For example, this code:
198+
199+
```csharp
200+
var params = new {
201+
status = 1,
202+
priority = "high",
203+
ids = new [] { "123", "456" }
204+
};
205+
request.AddObject(params);
206+
```
207+
208+
is equivalent to:
209+
210+
```csharp
211+
request.AddParameter("status", 1);
212+
request.AddParameter("priority", "high");
213+
request.AddParameter("ids", "123,456");
214+
```
215+
216+
Remember that `AddObject` only works if your properties have primitive types. It also works with collections of primitive types as shown above.
217+
194218
### Url Segment
195219

196220
Unlike `GetOrPost`, this `ParameterType` replaces placeholder values in the `RequestUrl`:

0 commit comments

Comments
 (0)