Skip to content

Commit c4ce007

Browse files
committed
Adds sample for multipart/form-data
1 parent f8618cd commit c4ce007

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.markdown

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,26 @@ begin
157157
> **NOTE:** Async request is only supported for `WinHTTP`.
158158
> Any thought about how to implement this feature for `Indy` and `WinInet` are welcome.
159159
160+
- **MULTIPART/FORM-DATA**
161+
162+
Send forms with file attachments is possible by declaring a class that represents the form fields and inherits from `TMultiPartFormData`.
163+
164+
```Delphi
165+
TRequestData = class(TMultiPartFormData)
166+
name: string;
167+
ticket_number: integer;
168+
signed_contract: TMultiPartFormAttachment;
169+
end;
170+
```
171+
```Delphi
172+
Request := TRequestData.Create;
173+
Request.name := 'Fernando';
174+
Request.ticket_number := 123;
175+
Request.signed_contract := TMultiPartFormAttachment.Create('c:\contract.txt', 'text/plain', 'contract.txt');
176+
177+
Result := RestClient.Resource(URL).Post(Request);
178+
```
179+
160180
## Authentication
161181

162182
RestClient supports HTTP Basic authentication. You can set credentials using the `SetCredentials` method before making the first request:

0 commit comments

Comments
 (0)