Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Guides   Examples
New in version: 8.0   8.1   8.2   8.3   8.4   8.5   9.0   9.1   9.2   9.3    Statistic  


Sets transfer to be a HTTP Post.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
CURL 2.5 Yes Yes Yes Yes Yes
MBS( "CURL.SetOptionPost"; curl; Value )   More


Parameter Description Example value
curl The CURL session handle. $curl
Value Whether this is a POST request. 1


Returns "OK" on success.


Sets transfer to be a HTTP Post.
A parameter set to 1 tells the library to do a regular HTTP post. This will also make the library use a "Content-Type: application/x-www-form-urlencoded" header. (This is by far the most commonly used POST method).

Use one of CURL.SetOptionPostFields options to specify what data to post and CURL.SetOptionPostFieldSize to set the data size.

Optionally, you can provide data to POST using the CURL.SetInput* functions but then you must make sure to not set CURL.SetOptionPostFields to anything but "". When providing data with a callback, you must transmit it using chunked transfer-encoding or you must set the size of the data with the SetOptionPostFieldSize or CURL.SetOptionPostFieldSizeLarge option. To enable chunked encoding, you simply pass in the appropriate Transfer-Encoding header.

You can override the default POST Content-Type: header by setting your own with CURL.SetOptionHTTPHeader.

Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header. You can disable this header with CURL.SetOptionHTTPHeader as usual.

If you use POST to a HTTP 1.1 server, you can send data without knowing the size before starting the POST if you use chunked encoding. You enable this by adding a header like "Transfer-Encoding: chunked" with CURL.SetOptionHTTPHeader. With HTTP 1.0 or without chunked transfer, you must specify the size in the request.

When setting CURL.SetOptionPost to 1, it will automatically set CURL.SetOptionNoBody to 0 (since 7.14.1).

If you issue a POST request and then want to make a HEAD or GET using the same re-used handle, you must explicitly set the new request type using CURL.SetOptionNoBody or CURL.SetOptionGet or similar.

For debugging, the website is very useful. It allows you to see what is received on the other end for a post operation.

If you need GET, please use CURL.SetOptionGet. If you need DELETE, PATCH or others, please use CURL.SetOptionCustomRequest function.

See also POST option in CURL manual.


Enables POST option:

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

Using Rosette web service:

# Start new CURL transfer
Set Variable [$curl; Value:MBS("CURL.New")]
# Set options like Verbose Debug Messages
Set Variable [$result; Value:MBS("CURL.SetOptionVerbose"; $curl; 1)]
# the url of webservice
Set Variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; "")]
# the header info for tagging, API Key comes from a global field.
Set Variable [$result; Value:MBS("CURL.SetOptionHTTPHeader"; $curl; "user_key: " & RosetteAPISettings::RosetteAPIKey; "Content-Type: application/json"; "Accept: application/json" )]
# We want a POST transfer:
Set Variable [$result; Value:MBS("CURL.SetOptionPost"; $curl; 1 )]
# Build JSON using the plugin function to properly encode a string:
Set Variable [$request; Value:"{\"content\": " & MBS("JSON.CreateString"; TextData::TextAsInput) & "}"]
Set Variable [$result; Value:MBS("CURL.SetOptionPostFields"; $curl; $request)]
#show our JSON in a field for debugging:
Set Field [TextData::CURLInput; $request]
#Run transfer
Set Variable [$result; Value:MBS("CURL.Perform"; $curl)]
# Check result and debug messages
Set Field [TextData::CurlDebug; MBS("CURL.GetDebugAsText"; $curl)]
Set Field [TextData::CurlOutput; MBS("CURL.GetResultAsText"; $curl)]
# Cleanup
Set Variable [$r; Value:MBS("CURL.Cleanup"; $curl)]

Charge with Stripe webservice:

# new session
Set Variable [$curl; Value:MBS("CURL.New")]
# use stripe charge API
Set Variable [$result; Value:MBS("CURL.SetOptionURL"; $curl; "")]
# set user name
Set Variable [$result; Value:MBS("CURL.SetOptionUsername"; $curl; "sk_test_ your id here")]
# make a post with given content:
Set Variable [$result; Value:MBS("CURL.SetOptionPost"; $curl; 1)]
Set Variable [$result; Value:MBS("CURL.SetOptionPostFields"; $curl; "amount=400&currency=usd&[object]=card&source[number]=4242424242424242&source[exp_month]=12&source[exp_year]=2017&source[cvc]=123")]
# perform
Set Field [CURL Test::Result; MBS("CURL.Perform"; $curl)]
# now check result
Set Field [CURL Test::Text; MBS("CURL.GetResultAsText"; $curl; "UTF8")]
Set Field [CURL Test::header; MBS("CURL.GetDebugAsText"; $curl)]
# cleanup
Set Variable [$result; Value:MBS("CURL.Cleanup"; $curl)]

See also

Example Databases

Blog Entries

Created 18th August 2014, last changed 18th July 2019

CURL.SetOptionPort   -   CURL.SetOptionPostFieldSize

Feedback: Report problem or ask question.

MBS Xojo Plugins