Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.1   6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4    Statistic  


Sets a custom request.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
CURL 2.5 Yes Yes Yes Yes Yes

MBS( "CURL.SetOptionCustomRequest"; Handle; Value { ; Encoding } )


Parameter Description Example value
Handle The CURL session handle. $curl
Value The custom request string. "PUT"
Encoding Optional
The text encoding for text parameter.
Default is UTF-8.
Possible encoding names: ANSI, Arabic-Mac, Arabic-Win, Baltic-Win, CentralEurope-Mac, ChineseSimp-Mac, ChineseSimp-Win, ChineseTrad-Mac, ChineseTrad-Win, Cyrillic-Mac, Cyrillic-Win, EasternEurope-Win, Greek-Mac, Greek-Win, Hebrew-Mac, Hebrew-Win, ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, ISO-8859-9, ISO-8859-15, Korean-Johab, Korean-Mac, Korean-Win, Latin1, Mac, Native, ShiftJIS-Mac, ShiftJIS-Win, Turkish-Mac, Turkish-Win, UTF-8, DOS or Windows. Pass native to use the native encoding of the current platform.


Returns "OK" on success.


Sets a custom request.
Pass a text string as parameter. It will be used instead of GET or HEAD when doing an HTTP request, or instead of LIST or NLST when doing a FTP directory listing. This is useful for doing DELETE or other more or less obscure HTTP requests. Don't do this at will, make sure your server supports the command first.

When you change the request method by setting CURL.SetOptionCustomRequest to something, you don't actually change how libcurl behaves or acts in regards to the particular request method, it will only change the actual string sent in the request.

For example: if you tell libcurl to do a HEAD request, but then change the request to a "GET" with CURL.SetOptionCustomRequest you'll still see libcurl act as if it sent a HEAD even when it does send a GET.

To switch to a proper HEAD, use CURL.SetOptionNoBody, to switch to a proper POST, use CURL.SetOptionPost and CURL.SetOptionPostFields.

Restore to the internal default by setting this to "".

Many people have wrongly used this option to replace the entire request with their own, including multiple headers and POST contents. While that might work in many cases, it will cause libcurl to send invalid requests and it could possibly confuse the remote server badly. Use CURL.SetOptionPost and CURL.SetOptionPostFields to set POST data. Use CURL.SetOptionHTTPHeader to replace or extend the set of headers sent by libcurl. Use CURL.SetOptionHTTPVersion to change HTTP version.


Sets request POST:

MBS( "CURL.SetOptionPost"; $curl; 1 )

Advanced file listing for FTP:

MBS( "CURL.SetOptionCustomRequest"; $curl; "MLSD" )

Set delete request:

MBS( "CURL.SetOptionCustomRequest"; $curl; "DELETE" )

Fetch email flags for IMAP:

MBS( "CURL.SetOptionCustomRequest"; $curl; "FETCH 1:* FLAGS" )

Sets custom request PATCH:

MBS( "CURL.SetOptionCustomRequest"; $curl; "PATCH" )

IMAP fetch all email list with MessageID included:

Set Variable [$r; Value:MBS("CURL.SetOptionCustomRequest"; $curl; "FETCH 1:* (FLAGS BODY[HEADER.FIELDS (Message-Id)])")]

Mark email to be deleted via IMAP:

Set Variable [$r; Value:MBS("CURL.SetOptionCustomRequest"; $curl; "STORE " & $EmailID & " +FLAGS (\DELETED)")]

Delete emails via IMAP:

Set Variable [$r; Value:MBS("CURL.SetOptionCustomRequest"; $curl; "EXPUNGE")]

Delete email via POP3:

#Start new session
Set Variable [$curl; Value:MBS("CURL.New")]
#You can specify the message either in the URL or DELE command
Set Variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; "pop3://")]
#put credentials in place
Set Variable [$result; Value:MBS("CURL.SetOptionUsername"; $curl; "")]
Set Variable [$result; Value:MBS("CURL.SetOptionPassword"; $curl; "xxx")]
#Set the DELE command
Set Variable [$result; Value:MBS("CURL.SetOptionCustomRequest"; $curl; "DELE")]
#Do not perform a transfer as DELE returns no data
Set Variable [$result; Value:MBS("CURL.SetOptionNoBody"; $curl; 1)]
#Perform the custom request
Set Field [CURL Test::Result; MBS("CURL.Perform"; $curl)]
#Check result
Set Field [CURL Test::Text; MBS("CURL.GetResultAsText"; $curl; "UTF8")]
Set Field [CURL Test::debug; MBS("CURL.GetDebugAsText"; $curl)]
Set Variable [$result; Value:MBS("CURL.Cleanup"; $curl)]

Set deleted flag for email with IMAP:

Set Variable [$r; Value:MBS("CURL.SetOptionCustomRequest"; $curl; "STORE 123 +Flags \\Deleted")]

See also

Example Databases

CURL.SetOptionCookieSession   -   CURL.SetOptionDNSCacheTimeout

Feedback: Report problem or ask question.

MBS Xojo Plugins