Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
10.1
10.2
10.3
10.4
10.5
11.0
11.1
11.2
11.3
11.4
Statistic
FMM
Blog
Sets the http header list.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
CURL | 2.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example |
---|---|---|
curl | The CURL session handle. | $curl |
Values... | Header values | "Content-Type: text/xml" |
Returns "OK" on success.
See also HTTPHEADER option in CURL manual.
Set text/xml content type:
MBS( "CURL.SetOptionHTTPHeader"; $curl; "Content-Type: text/xml" )
Set two custom headers:
MBS( "CURL.SetOptionHTTPHeader"; $curl; "MyHeader1: hello"; "MyHeader2: world" )
Call with three parameters:
MBS( "CURL.SetOptionHTTPHeader"; handle; $value1; $value2; $value3 )
For SOAP, set content type and disable Expect header:
MBS("CURL.SetOptionHTTPHeader"; $curl; "Expect:"; "Content-Type: text/xml")
Set content type including a soap action:
MBS( "CURL.SetOptionHTTPHeader"; $curl; "Content-Type: application/soap+xml;charset=UTF-8;action=\"urn:sap-com:document:sap:soap:functions:mc-style:ZMF_WS_00:ZmfWs00Request\"" )
Request no cached copy:
MBS("CURL.SetOptionHTTPHeader"; $curl; "Cache-Control: no-cache")
Set content type for URL encoded form data:
MBS( "CURL.SetOptionHTTPHeader"; $curl; "Content-Type: application/x-www-form-urlencoded" )
Using a bearer for a webservice:
MBS( "CURL.SetOptionHTTPHeader"; $curl; "Authorization: Bearer a92eabb9-76f9-42ee-b280-bcd15cb2e9db"; "Content-Type: application/json")
Set SOAP Action and Content-Type for webservice:
MBS("CURL.SetOptionHTTPHeader"; $curl;
"Content-Type: text/xml;charset=\"utf-8\"";
"SOAPAction: \"" & $SoapRequestName &"\"")
Query current account for Dropbox:
# Start new session
Set Variable [ $curl ; Value: MBS("CURL.New") ]
# Set URL to load (HTTP, HTTPS, FTP, FTPS, SFTP, etc.)
Set Variable [ $result ; Value: MBS("CURL.SetOptionURL"; $curl; "https://api.dropboxapi.com/2/users/get_current_account") ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionCustomRequest"; $curl; "POST") ]
Set Variable [ $result ; Value: MBS("CURL.SetOptionHTTPHeader"; $curl; "Accept: */*"; "Authorization: Bearer xxx"; "Cache-Control: no-cache"; "accept-encoding: gzip, deflate"; "cache-control: no-cache"; "content-length:") ]
# RUN now
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) ]
# Cleanup
Set Variable [ $result ; Value: MBS("CURL.Release"; $curl) ]
OAuth2 Token authentication with passing credentials via POST:
Set Variable [ $Curl ; Value: MBS("CURL.New") ]
#
# Change path to your CACert PEM File.
Set Variable [ $CacertPath ; Value: "C:\Users\Public\cacert.pem" ]
// Set Variable [ $Result ; Value: MBS( "CURL.SetOptionCAInfo"; $curl; $cacertPath ) ]
// Set Variable [ $Result ; Value: MBS( "CURL.SetOptionSSLVerifyHost"; $curl; 2 ) ]
// Set Variable [ $Result ; Value: MBS( "CURL.SetOptionSSLVerifyPeer"; $curl; 1 ) ]
Set Variable [ $Result ; Value: MBS("CURL.SetOptionVerbose"; $curl; 1) ]
#
# credentials
Set Variable [ $secret ; Value: "xxx" ]
Set Variable [ $client ; Value: "yyy" ]
Set Variable [ $domain ; Value: "zzz" ]
Set Variable [ $Result ; Value: MBS("CURL.SetOptionURL"; $curl; "https://" & $domain & "/auth/realms/demo/protocol/openid-connect/token") ]
#
# POST with form encoding
Set Variable [ $result ; Value: MBS("CURL.SetOptionHTTPHeader"; $curl; "content-type: application/x-www-form-urlencoded") ]
Set Variable [ $Result ; Value: MBS("CURL.SetOptionPostFields"; $curl; "grant_type=client_credentials&client_id="& $client & "&client_secret=" & $secret) ]
#
# run it
Set Variable [ $Result ; Value: MBS("CURL.Perform"; $curl) ]
Set Variable [ $DebugText ; Value: MBS("CURL.GetDebugAsText"; $curl) ]
Set Variable [ $ResultText ; Value: MBS("CURL.GetResultAsText"; $curl) ]
If [ $result = "OK" ]
# extract token
Set Variable [ $Token ; Value: JSONGetElement ( $ResultText; "access_token" ) ]
Set Field [ tbl_debugger::token ; $Token ]
End If
Set Field [ tbl_debugger::header ; $DebugText ]
Set Variable [ $Result ; Value: MBS("CURL.Release"; $curl) ]
Created 18th August 2014, last changed 22nd June 2021
CURL.SetOptionHTTPContentDecoding - CURL.SetOptionHTTPProxyTunnel
Feedback: Report problem or ask question.