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:
9.3
9.4
9.5
10.0
10.1
10.2
10.3
10.4
10.5
11.0
Statistic
FMM
Blog
CURL.SetOptionHTTPHeader
Sets the http header list.
Component | Version | macOS | Windows | Linux | Server | FileMaker iOS SDK |
CURL | 2.5 | Yes | Yes | Yes | Yes | Yes |
Parameters
Parameter | Description | Example |
---|---|---|
curl | The CURL session handle. | $curl |
Values | Header values | "Content-Type: text/xml" |
Result
Returns "OK" on success.
Description
Sets the http header list.Pass a list of HTTP headers to pass to the server in your HTTP request. If you add a header that is otherwise generated and used by libcurl internally, your added one will be used instead. If you add a header with no content as in 'Accept:' (no data on the right side of the colon), the internally used header will get disabled. Thus, using this option you can add new headers, replace internal headers and remove internal headers. To add a header with no content, make the content be two quotes: "". The headers included in the linked list must not be CRLF-terminated, because curl adds CRLF after each header item. Failure to comply with this will result in strange bugs because the server will most likely ignore part of the headers you specified.
The first line in a request (containing the method, usually a GET or POST) is not a header and cannot be replaced using this option. Only the lines following the request-line are headers. Adding this method line in this list of headers will only cause your request to send an invalid header.
Pass a no parameters to this to reset back to no custom headers.
The most commonly replaced headers have "shortcuts" in the options CURL.SetOptionCookie, CURL.SetOptionUserAgent and CURL.SetOptionReferer.
This option takes a list of items. So this function takes a variable number of arguments. If you call function with 2 parameters, you set an empty list. If you call it with 5 parameters, you set a list with 3 values.
Do not pass special headers like Content-Length as this is set based on the given input via CURL.SetOptionPostFields. Do not set Content-Encoding as that is controlled by CURL.SetOptionAcceptEncoding.
See also HTTPHEADER option in CURL manual.
Examples
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) ]
See also
- CURL.GetOptionHTTPHeader
- CURL.GetOptionProxyHeader
- CURL.SetOptionFTPUsePret
- CURL.SetOptionHTTPVersion
- CURL.SetOptionPostFields
- CURL.SetOptionProxyHeader
- CURL.SetOptionReferer
- CURL.SetOptionSSLCert
- CURL.SetOptionSSLKey
- CURL.SetOptionUserAgent
Example Databases
- CURL/WebServices/AdobeSign WebService
- CURL/WebServices/CURL FMS Admin API v17
- CURL/WebServices/CURL FMS Admin API v18
- CURL/WebServices/ebay webservice/ebay Webservice
- CURL/WebServices/Magento2 REST API
- CURL/WebServices/Sales Force Test
- CURL/WebServices/Swiss Post Addresscheck V4-02-00
- CURL/WebServices/Swiss Post Addresscheck
- CURL/WebServices/TinyURL
- CURL/WebServices/Twitter oAuth
Blog Entries
- Translating Insert from URL options for CURL to MBS Plugin calls
- Using Apple's Global Service Exchange web service in FileMaker
- Let CURL handle cookie list
- MBS FileMaker Plugin, version 8.2pr3
- LogicalDOC Webservice
- Comparing Base Elements Plugin to MBS FileMaker Plugin
- Using Apple's Global Service Exchange web service in FileMaker
- Using NetVerify web service with FileMaker
- Swiss Post Webservice to verify addresses
- Using CURL with Rosette web service
FileMaker Magazin
Release notes
- Version 8.2
- Changed curl options taking lists like CURL.SetOptionHTTPHeader to accept lists as parameters.
Created 18th August 2014, last changed 30th April 2020
CURL.SetOptionHTTPContentDecoding - CURL.SetOptionHTTPProxyTunnel
Feedback: Report problem or ask question.

Links
MBS Xojo blog