Skip to main content

Request():setFileContent()

Attach content the macro already holds as if it were an uploaded file.

Signature​

setFileContent(name: string, fileName: string, content: string): Request
setFileContent(name: string, fileName: string, content: string, contentType: string): Request

Parameters​

ParameterTypeDescription
namestringForm field name the server expects
fileNamestringFile name shown to the server
contentstringFile content as a UTF-8 string
contentTypestringOptional MIME type, for example text/plain

Returns

Request, so calls chain.

Description​

The content is encoded as UTF-8 bytes; it is not base64-decoded. For binary files, build the bytes yourself or use the app's file upload flow instead. When a request has file content, the parameters and files are sent as a multipart/form-data body.

Example​

Request("https://api.example.com/upload")
:setFileContent("file", "note.txt", "hello from a macro", "text/plain")
:post()

Compatible Version: 1.0.0.37 and up