Skip to content

AddFile

Adds a file as a multipart form field.

1
myRestRequest.AddFile(name: string, fileId: string):RestRequest

Parameters

string name
    The name of the form field.

string fileId
    The ID of the file.

Returns

The current RestRequest instance.

Remarks

The file name and MIME type of the stored file are sent with the content.

Examples

Upload a file with form fields

1
2
3
4
5
6
var result = $Rest.Create('https://api.example.com/')
    .Request('documents')
    .AddParameter('title', $Xml.Evaluate('Title'))
    .AddFile('file', $Xml.Evaluate('Attachment'))
    .Post()
    .ToJson();

See Also