CURL.Perform
------------

Perform a file transfer.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [CURL](component_CURL.md) | [2.5](newinversion25.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "CURL.Perform"; curl ) 

**MBS**( **"CURL.Perform";** /\* Perform a file transfer. \*/  
**$curl**) /\* The CURL session handle. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| curl | The CURL session handle. | $curl |

### Result

Error OK or error.

### Description

Perform a file transfer.  
This function is called after the init and all the options are set, and will perform the transfer as described in the options. It must be called with the same handle as input as the [CURL.New](CURLNew.md) call returned.  
  
You can do any amount of calls to CURL.Perform while using the same handle. If you intend to transfer more than one file, you are even encouraged to do so. CURL will then attempt to re-use the same connection for the following transfers, thus making the operations faster, less CPU intense and using less network resources. Just note that you will have to use the option functions between the invokes to set options for the following CURL.Perform.  
  
You must never call this function simultaneously from two places using the same handle. Let the function return first before invoking it another time. If you want parallel transfers, you must use several curl handles.  
  
While transfer is running, your FileMaker application is blocked. It's useful to show progress with using [CURL.SetUpdateProgressDialog](CURLSetUpdateProgressDialog.md). Or you use [CURL.PerformInBackground](CURLPerformInBackground.md) or [CURL.PerformAsync](CURLPerformAsync.md) to run the transfer in background.  
  
Internal buffer for output, debug and header data is cleared before the perform.  
  
This function returns error codes. If you get an error, please use [CURL.GetDebugMessages](CURLGetDebugMessages.md) to read the transcription of the transfer and look for error messages from server.  
Typical error codes are 6 for a wrong domain name in the URL, 67 for wrong name/password combination, 60 for missing/bad SSL settings, 1 for an unsupported protocol.  
  
In case of error 60, please decide what SSL policy you want and use our SSL options. e.g. use [CURL.SetOptionSSLVerifyHost](CURLSetOptionSSLVerifyHost.md) and [CURL.SetOptionSSLVerifyPeer](CURLSetOptionSSLVerifyPeer.md) to disable SSL security or use [CURL.SetOptionCAInfo](CURLSetOptionCAInfo.md) to point CURL to a certificate.  
  
No error means the data transfer was okay, but it doesn't tell you if for example a web server reported an error. Please check [CURL.GetResponseCode](CURLGetResponseCode.md) for HTTP requests to get the HTTP status code. e.g. 404 if file is not found.  
  
The list of possible error codes:  
  
| Name | Number | Description |
|---|---|---|
| CURLE\_OK | 0 | No error. |
| CURLE\_UNSUPPORTED\_PROTOCOL | 1 | Unsupported protocol. |
| CURLE\_FAILED\_INIT | 2 | Initialization failed or option not available. |
| CURLE\_URL\_MALFORMAT | 3 | URL has wrong format. |
| CURLE\_COULDNT\_RESOLVE\_PROXY | 5 | DNS didn't return proxy IP. |
| CURLE\_COULDNT\_RESOLVE\_HOST | 6 | DNS didn't return IP for host. |
| CURLE\_COULDNT\_CONNECT | 7 | Connection failed. |
| CURLE\_FTP\_WEIRD\_SERVER\_REPLY | 8 | FTP error. |
| CURLE\_REMOTE\_ACCESS\_DENIED | 9 | A service was denied by the server due to lack of access when login fails this is not returned. |
| CURLE\_FTP\_WEIRD\_PASS\_REPLY | 11 | FTP error. |
| CURLE\_FTP\_WEIRD\_PASV\_REPLY | 13 | FTP error. |
| CURLE\_FTP\_WEIRD\_227\_FORMAT | 14 | FTP error. |
| CURLE\_FTP\_CANT\_GET\_HOST | 15 | FTP error. |
| CURLE\_FTP\_COULDNT\_SET\_TYPE | 17 | FTP set command failed. |
| CURLE\_PARTIAL\_FILE | 18 | Only a part of the file was downloaded. |
| CURLE\_FTP\_COULDNT\_RETR\_FILE | 19 | File not found. |
| CURLE\_QUOTE\_ERROR | 21 | quote command failure |
| CURLE\_HTTP\_RETURNED\_ERROR | 22 | HTTP returned an error. |
| CURLE\_WRITE\_ERROR | 23 | Write error. |
| CURLE\_UPLOAD\_FAILED | 25 | failed upload "command" |
| CURLE\_READ\_ERROR | 26 | couldn't open/read from file |
| CURLE\_OUT\_OF\_MEMORY | 27 | Out Of memory |
| CURLE\_OPERATION\_TIMEDOUT | 28 | the timeout time was reached |
| CURLE\_FTP\_PORT\_FAILED | 30 | FTP PORT operation failed |
| CURLE\_FTP\_COULDNT\_USE\_REST | 31 | the REST command failed |
| CURLE\_RANGE\_ERROR | 33 | RANGE "command" didn't work |
| CURLE\_HTTP\_POST\_ERROR | 34 | HTTP Post failed. |
| CURLE\_SSL\_CONNECT\_ERROR | 35 | wrong when connecting with SSL |
| CURLE\_BAD\_DOWNLOAD\_RESUME | 36 | couldn't resume download |
| CURLE\_FILE\_COULDNT\_READ\_FILE | 37 | Failed to read file. |
| CURLE\_LDAP\_CANNOT\_BIND | 38 | LDAP can't connect. |
| CURLE\_LDAP\_SEARCH\_FAILED | 39 | LDAP Search failed. |
| CURLE\_FUNCTION\_NOT\_FOUND | 41 | Function not found. |
| CURLE\_ABORTED\_BY\_CALLBACK | 42 | Transfer aborted with [CURL.Cancel](CURLCancel.md). |
| CURLE\_BAD\_FUNCTION\_ARGUMENT | 43 | Bad parameters. |
| CURLE\_INTERFACE\_FAILED | 45 | CURL.OptionInterface failed |
| CURLE\_TOO\_MANY\_REDIRECTS | 47 | catch endless re-direct loops |
| CURLE\_UNKNOWN\_TELNET\_OPTION | 48 | User specified an unknown option |
| CURLE\_TELNET\_OPTION\_SYNTAX | 49 | Malformed telnet option |
| CURLE\_PEER\_FAILED\_VERIFICATION | 51 | peer's certificate or fingerprint wasn't verified fine |
| CURLE\_GOT\_NOTHING | 52 | when this is a specific error |
| CURLE\_SSL\_ENGINE\_NOTFOUND | 53 | SSL crypto engine not found |
| CURLE\_SSL\_ENGINE\_SETFAILED | 54 | can not set SSL crypto engine as default |
| CURLE\_SEND\_ERROR | 55 | failed sending network data |
| CURLE\_RECV\_ERROR | 56 | failure in receiving network data |
| CURLE\_SSL\_CERTPROBLEM | 58 | problem with the local certificate |
| CURLE\_SSL\_CIPHER | 59 | couldn't use specified cipher |
| CURLE\_SSL\_CACERT | 60 | problem with the CA cert (path?) |
| CURLE\_BAD\_CONTENT\_ENCODING | 61 | Unrecognized transfer encoding |
| CURLE\_LDAP\_INVALID\_URL | 62 | Invalid LDAP URL |
| CURLE\_FILESIZE\_EXCEEDED | 63 | Maximum file size exceeded |
| CURLE\_USE\_SSL\_FAILED | 64 | Requested FTP SSL level failed |
| CURLE\_SEND\_FAIL\_REWIND | 65 | Sending the data requires a rewind that failed |
| CURLE\_SSL\_ENGINE\_INITFAILED | 66 | failed to initialise ENGINE |
| CURLE\_LOGIN\_DENIED | 67 | user, password or similar was not accepted and we failed to login |
| CURLE\_TFTP\_NOTFOUND | 68 | file not found on server |
| CURLE\_TFTP\_PERM | 69 | permission problem on server |
| CURLE\_REMOTE\_DISK\_FULL | 70 | out of disk space on server |
| CURLE\_TFTP\_ILLEGAL | 71 | Illegal TFTP operation |
| CURLE\_TFTP\_UNKNOWNID | 72 | Unknown transfer ID |
| CURLE\_REMOTE\_FILE\_EXISTS | 73 | File already exists |
| CURLE\_TFTP\_NOSUCHUSER | 74 | No such user |
| CURLE\_CONV\_FAILED | 75 | conversion failed |
| CURLE\_CONV\_REQD | 76 | caller must register conversion callbacks |
| CURLE\_SSL\_CACERT\_BADFILE | 77 | could not load CACERT file, missing or wrong format |
| CURLE\_REMOTE\_FILE\_NOT\_FOUND | 78 | remote file not found |
| CURLE\_SSH | 79 | error from the SSH layer, somewhat generic so the error message will be of interest when this has happened |
| CURLE\_SSL\_SHUTDOWN\_FAILED | 80 | Failed to shut down the SSL connection |
| CURLE\_AGAIN | 81 | socket is not ready for send/recv, wait till it's ready and try again. |
| CURLE\_SSL\_CRL\_BADFILE | 82 | could not load CRL file, missing or wrong format. |
| CURLE\_SSL\_ISSUER\_ERROR | 83 | Issuer check failed. |
| CURLE\_FTP\_PRET\_FAILED | 84 | a PRET command failed |
| CURLE\_RTSP\_CSEQ\_ERROR | 85 | mismatch of RTSP CSeq numbers |
| CURLE\_RTSP\_SESSION\_ERROR | 86 | mismatch of RTSP Session Identifiers |
| CURLE\_FTP\_BAD\_FILE\_LIST | 87 | unable to parse FTP file list |
| CURLE\_CHUNK\_FAILED | 88 | chunk callback reported error |

  
With SFTP, you can get logged error "Upload failed: Operation failed (4/-31)" when upload uses path to folder instead of file in URL.  
### Examples

Query a REST API:

 # new session   
Set Variable \[$curl ; MBS ( "[CURL.New](CURLNew.md)" ) \]  
\# set URL for this REST API   
Set Variable \[$r ; MBS ("[CURL.SetOptionURL](CURLSetOptionURL.md)"; $curl ; "https://example.test/wc-api/v2/products") \]  
\# make a post with some data   
Set Variable \[$r ; MBS ("[CURL.SetOptionPost](CURLSetOptionPost.md)"; $curl ; 1) \]  
Set Variable \[$r ; MBS ("[CURL.SetOptionPostFields](CURLSetOptionPostFields.md)"; $curl ; "{product:{...}}"; "UTF-8") \]  
\# set credentials   
Set Variable \[$r ; MBS ("[CURL.SetOptionUserName](CURLSetOptionUserName.md)"; $curl ; "consumer\_key") \]  
Set Variable \[$r ; MBS ("[CURL.SetOptionPassword](CURLSetOptionPassword.md)"; $curl ; "consumer\_secret") \]  
\# add header option   
Set Variable \[$r ; MBS ("[CURL.SetOptionHTTPHeader](CURLSetOptionHTTPHeader.md)"; $curl ; "Content-Type: application/json"; "Expect:" ) \]  
  
\# run it!   
Set Variable \[$Error ; MBS ( "CURL.Perform"; $curl ) \]  
\# check debug messages   
Set Variable \[$Messages ; MBS ("[CURL.GetDebugMessages](CURLGetDebugMessages.md)"; $curl ) \]  
\# check result   
Set Variable \[$Output ; MBS ("[CURL.GetResultAsText](CURLGetResultAsText.md)"; $curl ) \]  
\# and cleanup   
Set Variable \[$r ; MBS ( "[CURL.Release](CURLRelease.md)"; $curl ) \]  
Run a generic POST request for REST or SOAP web service:

 # new session   
Set Variable \[$curl ; Value:MBS ("[CURL.New](CURLNew.md)")\]  
\# use stripe charge API   
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionURL](CURLSetOptionURL.md)"; $curl ; "https://someURL/service")\]  
\# set user name and password if needed:   
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionUserName](CURLSetOptionUserName.md)"; $curl ; "user name")\]  
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionPassword](CURLSetOptionPassword.md)"; $curl ; "password")\]  
\# set some additional headers, which may include custom authorization and content types:   
Set Variable \[$result ; Value:MBS ( "[CURL.SetOptionHTTPHeader](CURLSetOptionHTTPHeader.md)"; $curl ; "Authorization: Bearer a92eabb9-76f9-42ee-b280-bcd15cb2e9db"; "Content-Type: application/json" ) \]  
\# make a post with given content:   
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionPostFields](CURLSetOptionPostFields.md)"; $curl ; $json ) \]  
\# perform   
Set Field \[CURL Test::Result ; MBS ("CURL.Perform"; $curl )\]  
\# now check result   
Set Field \[CURL Test::Text ; MBS ("[CURL.GetResultAsText](CURLGetResultAsText.md)"; $curl ; "UTF8")\]  
Set Field \[CURL Test::header ; MBS ("[CURL.GetDebugMessages](CURLGetDebugMessages.md)"; $curl )\]  
\# cleanup   
Set Variable \[$result ; Value:MBS ("[CURL.Release](CURLRelease.md)"; $curl )\]  
Using Rosette web service:

 # Start new CURL transfer   
Set Variable \[$curl ; Value:MBS ("[CURL.New](CURLNew.md)")\]  
\# Set options like Verbose Debug Messages   
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionVerbose](CURLSetOptionVerbose.md)"; $curl ; 1)\]  
\# the url of webservice   
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionURL](CURLSetOptionURL.md)"; $curl ; "https://api.rosette.com/rest/v1/morphology/parts-of-speech")\]  
\# the header info for tagging, API Key comes from a global field.   
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionHTTPHeader](CURLSetOptionHTTPHeader.md)"; $curl ; "user\_key: " &amp; RosetteAPISettings::RosetteAPIKey ; "Content-Type: application/json"; "Accept: application/json" )\]  
\# We want a POST transfer:   
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionPost](CURLSetOptionPost.md)"; $curl ; 1 )\]  
\# Build JSON using the plugin function to properly encode a string:   
Set Variable \[$request ; Value:"{\\"content\\": " &amp; MBS ("[JSON.CreateString](JSONCreateString.md)"; TextData::TextAsInput ) &amp; "}"\]  
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionPostFields](CURLSetOptionPostFields.md)"; $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.GetDebugMessages](CURLGetDebugMessages.md)"; $curl )\]  
Set Field \[TextData::CurlOutput ; MBS ("[CURL.GetResultAsText](CURLGetResultAsText.md)"; $curl )\]  
\# Cleanup   
Set Variable \[$r ; Value:MBS ("[CURL.Release](CURLRelease.md)"; $curl )\]  
Download a text from URL:

 # start new transfer   
Set Variable \[$curl ; Value:MBS ("[CURL.New](CURLNew.md)")\]  
\# set URL   
Set Variable \[$r ; Value:MBS ("[CURL.SetOptionURL](CURLSetOptionURL.md)"; $curl ; "https://www.mbsplugins.eu/")\]  
\# run transfer   
Set Variable \[$ErrorCode ; Value:MBS ("CURL.Perform"; $curl )\]  
\# get result as text and debug messages:   
Set Variable \[$TextResult ; Value:MBS ( "[CURL.GetResultAsText](CURLGetResultAsText.md)"; $curl )\]  
Set Variable \[$DebugMessages ; Value:MBS ( "[CURL.GetDebugMessages](CURLGetDebugMessages.md)"; $curl )\]  
\# cleanup   
Set Variable \[$r ; Value:MBS ("[CURL.Release](CURLRelease.md)"; $curl )\]  
Download URL to temp file:

 Set Variable \[$curl ; Value:MBS ("[CURL.New](CURLNew.md)")\]  
\#this is URL to download   
Set Variable \[$url ; Value:"https://www.monkeybreadsoftware.com/filemaker/test.txt"\]  
\#get file name from URL   
Set Variable \[$name ; Value:MBS ( "[Path.LastPathComponent](PathLastPathComponent.md)"; $URL )\]  
\#now make temp file path   
Set Variable \[$path ; Value:MBS ( "[Path.AddPathComponent](PathAddPathComponent.md)"; MBS ( "[Folders.SystemTemporary](FoldersSystemTemporary.md)" ); $name )\]  
\#set URL to download   
Set Variable \[$r ; Value:MBS ("[CURL.SetOptionURL](CURLSetOptionURL.md)"; $curl ; $url )\]  
\#open destination file   
Set Variable \[$r ; Value:MBS ("[CURL.CreateOutputFile](CURLCreateOutputFile.md)"; $curl ; $path )\]  
\#run transfer   
Set Field \[CURL Test::Result ; MBS ("CURL.Perform"; $curl )\]  
\#close destination file   
Set Variable \[$r ; Value:MBS ("[CURL.CloseOutputFile](CURLCloseOutputFile.md)"; $curl )\]  
\#get debug messages   
Set Field \[CURL Test::debug ; MBS ("[CURL.GetDebugMessages](CURLGetDebugMessages.md)"; $curl )\]  
Set Variable \[$result ; Value:MBS ("[CURL.Release](CURLRelease.md)"; $curl )\]  
Query IP via ipinfo.io:

 Go to Layout \[“Table”\]  
New Record/Request  
\#Start new session   
Set Variable \[$curl ; Value:MBS ("[CURL.New](CURLNew.md)")\]  
\#Set URL to load (HTTP, HTTPS, FTP, FTPS, SFTP, etc.)   
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionURL](CURLSetOptionURL.md)"; $curl ; "http://ipinfo.io")\]  
\#RUN now   
Set Variable \[$result ; Value:MBS ("CURL.Perform"; $curl )\]  
\#Check result   
Set Field \[Table::DebugLog ; MBS ("[CURL.GetDebugMessages](CURLGetDebugMessages.md)"; $curl )\]  
Set Field \[Table::Result ; MBS ("[CURL.GetResultAsText](CURLGetResultAsText.md)"; $curl ; "UTF8")\]  
If \[$result = "OK"\]  
 #Check HTTP error code  
 Set Variable \[$response ; Value:MBS ("[CURL.GetResponseCode](CURLGetResponseCode.md)"; $curl )\]  
 If \[$response = 200\]  
 #Query values from JSON  
 Set Variable \[$json ; Value:MBS ( "[JSON.Parse](JSONParse.md)"; Table::Result )\]  
 Set Field \[Table::IP ; MBS ("[JSON.GetPathItem](JSONGetPathItem.md)"; $json ; "ip"; 1)\]  
 Set Field \[Table::Hostname ; MBS ("[JSON.GetPathItem](JSONGetPathItem.md)"; $json ; "hostname"; 1)\]  
 Set Field \[Table::City ; MBS ("[JSON.GetPathItem](JSONGetPathItem.md)"; $json ; "city"; 1)\]  
 Set Field \[Table::Region ; MBS ("[JSON.GetPathItem](JSONGetPathItem.md)"; $json ; "region"; 1)\]  
 Set Field \[Table::Country ; MBS ("[JSON.GetPathItem](JSONGetPathItem.md)"; $json ; "country"; 1)\]  
 Set Field \[Table::Location ; MBS ("[JSON.GetPathItem](JSONGetPathItem.md)"; $json ; "loc"; 1)\]  
 Set Field \[Table::Company or Provider; MBS ("[JSON.GetPathItem](JSONGetPathItem.md)"; $json ; "org"; 1)\]  
 Set Variable \[$r ; Value:MBS ( "[JSON.Release](JSONRelease.md)"; $json )\]  
 End If  
End If  
\#Cleanup   
Set Variable \[$result ; Value:MBS ("[CURL.Release](CURLRelease.md)"; $curl )\]  
Commit Records/Requests \[No dialog\]  
Query fedex for tracking status:

 #Start new session   
Set Variable \[$curl ; Value:MBS ("[CURL.New](CURLNew.md)")\]  
\#Set URL to load (HTTP, HTTPS, FTP, FTPS, SFTP, etc.)   
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionURL](CURLSetOptionURL.md)"; $curl ; "https://www.fedex.com/trackingCal/track/v1/shipments/trackingnumbers")\]  
\# set query content including the trackingNumber   
Set Variable \[$result ; Value: MBS ("[CURL.SetOptionPostFields](CURLSetOptionPostFields.md)"; $curl ; "{\\"TrackPackagesRequest\\":{\\"appType\\":\\"WTRK\\",\\"appDeviceType\\":\\"WTRK\\",\\"uniqueKey\\":\\"\\",\\"processingParameters\\":{},\\"trackingInfoList\\":\[{\\"trackNumberInfo\\":{\\"trackingNumber\\":\\"" &amp; $trackingNumber &amp; "\\",\\"trackingQualifier\\":\\"\\",\\"trackingCarrier\\":\\"\\"}}\]}}") \]  
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionHTTPHeader](CURLSetOptionHTTPHeader.md)"; $curl ; "Content-Type: application/json")\]  
\#RUN now   
Set Field \[CURL Test::Result ; MBS ("CURL.Perform"; $curl )\]  
\#Check result   
Set Field \[CURL Test::Text ; MBS ("[CURL.GetResultAsText](CURLGetResultAsText.md)"; $curl ; "UTF8")\]  
Set Field \[CURL Test::debug ; MBS ("[CURL.GetDebugMessages](CURLGetDebugMessages.md)"; $curl )\]  
\#Cleanup   
Set Variable \[$result ; Value:MBS ("[CURL.Release](CURLRelease.md)"; $curl )\]  
Send request to Apple's gsx webservice:

 Set Variable \[$XMLRequest ; Value:""\]  
\#Start new session   
Set Variable \[$curl ; Value:MBS ("[CURL.New](CURLNew.md)")\]  
\# URL for web service   
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionURL](CURLSetOptionURL.md)"; $curl ; "https://gsxapiut.apple.com:443/gsx-ws/services/emea/asp")\]  
\# Mark content as XML   
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionHTTPHeader](CURLSetOptionHTTPHeader.md)"; $curl ; "Content-Type: text/xml; charset=UTF-8")\]  
\# Pass XML content for request   
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionPostFields](CURLSetOptionPostFields.md)"; $curl ; $XMLRequest )\]  
\# Certificate and private key in one file   
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionSSLCert](CURLSetOptionSSLCert.md)"; $curl ; "/Users/cs/Keys/apple-cert+key.pem")\]  
\# Root certificates   
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionCAInfo](CURLSetOptionCAInfo.md)"; $curl ; "/Users/cs/Keys/cacert.pem")\]  
\# SSL Key is in PEM Format   
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionSSLCertType](CURLSetOptionSSLCertType.md)"; $curl ; "PEM")\]  
\# Password for key file   
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionKeyPassword](CURLSetOptionKeyPassword.md)"; $curl ; "xxx")\]  
\# SSL Verification on   
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionSSLVerifyPeer](CURLSetOptionSSLVerifyPeer.md)"; $curl ; 1)\]  
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionSSLVerifyHost](CURLSetOptionSSLVerifyHost.md)"; $curl ; 1)\]  
\# use TLS v1.2   
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionSSLVersion](CURLSetOptionSSLVersion.md)"; $curl ; 6)\]  
\#RUN now   
Set Field \[CURL Test::Result ; MBS ("CURL.Perform"; $curl )\]  
\#Check result   
Set Field \[CURL Test::Text ; MBS ("[CURL.GetResultAsText](CURLGetResultAsText.md)"; $curl ; "UTF8")\]  
Set Field \[CURL Test::debug ; MBS ("[CURL.GetDebugMessages](CURLGetDebugMessages.md)"; $curl )\]  
\#Cleanup   
Set Variable \[$result ; Value:MBS ("[CURL.Release](CURLRelease.md)"; $curl )\]  
Upload file from OS X to IBM Mainframe:

 Set Variable \[$debug ; Value:""\]  
Set Variable \[$curl ; Value:MBS ("[CURL.New](CURLNew.md)")\]  
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionUpload](CURLSetOptionUpload.md)"; $curl ; 1)\]  
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionUserName](CURLSetOptionUserName.md)"; $curl ; "xxx")\]  
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionPassword](CURLSetOptionPassword.md)"; $curl ; "yyy")\]  
Set Variable \[$result ; Value:MBS ( "[CURL.OpenInputFile](CURLOpenInputFile.md)"; $curl ; "/Users/gene/Desktop/MY.Logfile.txt")\]  
Set Variable \[$result ; Value:MBS ( "[CURL.SetOptionURL](CURLSetOptionURL.md)"; $curl ; "ftp://192.168 .1.4 :21/MY.LOGFILE1" )\]  
Set Variable \[$result ; Value:MBS ("[CURL.SetOptionVerbose](CURLSetOptionVerbose.md)"; $curl ; 1)\]  
Set Variable \[$result ; Value:MBS ( "[CURL.SetOptionTransferText](CURLSetOptionTransferText.md)"; $curl ; 1 )\]  
Set Variable \[$result ; Value:MBS ( "[CURL.SetOptionSSLVerifyPeer](CURLSetOptionSSLVerifyPeer.md)"; $curl ; 0 )\]  
Set Variable \[$result ; Value:MBS ( "[CURL.SetOptionSSLVerifyHost](CURLSetOptionSSLVerifyHost.md)"; $curl ; 0 )\]  
Set Variable \[$result ; Value:MBS ( "[CURL.SetOptionQuote](CURLSetOptionQuote.md)"; $curl ; "site RECFM=FB LRECL=1024")\]  
Set Variable \[$result ; Value:MBS ("CURL.Perform"; $curl )\]  
Set Variable \[$debug ; Value:MBS ("[CURL.GetDebugMessages](CURLGetDebugMessages.md)"; $curl )\]  
Set Variable \[$result ; Value:MBS ("[CURL.Release](CURLRelease.md)"; $curl )\]  
OAuth2 Token authentication with passing credentials via POST:

 Set Variable \[ $Curl ; Value: MBS ("[CURL.New](CURLNew.md)") \]   
\#   
\# Change path to your CACert PEM File.   
Set Variable \[ $CacertPath ; Value: "C:\\Users\\Public\\cacert.pem" \]   
// Set Variable \[ $Result ; Value: MBS ( "[CURL.SetOptionCAInfo](CURLSetOptionCAInfo.md)"; $curl ; $cacertPath ) \]   
// Set Variable \[ $Result ; Value: MBS ( "[CURL.SetOptionSSLVerifyHost](CURLSetOptionSSLVerifyHost.md)"; $curl ; 2 ) \]   
// Set Variable \[ $Result ; Value: MBS ( "[CURL.SetOptionSSLVerifyPeer](CURLSetOptionSSLVerifyPeer.md)"; $curl ; 1 ) \]   
Set Variable \[ $Result ; Value: MBS ("[CURL.SetOptionVerbose](CURLSetOptionVerbose.md)"; $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](CURLSetOptionURL.md)"; $curl ; "https://" &amp; $domain &amp; "/auth/realms/demo/protocol/openid-connect/token") \]   
\#   
\# POST with form encoding   
Set Variable \[ $result ; Value: MBS ("[CURL.SetOptionHTTPHeader](CURLSetOptionHTTPHeader.md)"; $curl ; "content-type: application/x-www-form-urlencoded") \]   
Set Variable \[ $Result ; Value: MBS ("[CURL.SetOptionPostFields](CURLSetOptionPostFields.md)"; $curl ; "grant\_type=client\_credentials&amp;client\_id="&amp; $client &amp; "&amp;client\_secret=" &amp; $secret ) \]   
\#   
\# run it   
Set Variable \[ $Result ; Value: MBS ("CURL.Perform"; $curl ) \]   
Set Variable \[ $DebugText ; Value: MBS ("[CURL.GetDebugMessages](CURLGetDebugMessages.md)"; $curl ) \]   
Set Variable \[ $ResultText ; Value: MBS ("[CURL.GetResultAsText](CURLGetResultAsText.md)"; $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](CURLRelease.md)"; $curl ) \]  
Publish a topic for MQTT server in a Let statement:

 Let(\[  
// Send in file MQTT  
curl = MBS ("[CURL.New](CURLNew.md)");  
// connect to MQTT server and send  
r = MBS ("[CURL.SetOptionURL](CURLSetOptionURL.md)"; curl; MQTT::URL );  
r = MBS ("[CURL.SetOptionPostFields](CURLSetOptionPostFields.md)"; curl; MQTT::Payload ; "UTF-8");  
//   
r = MBS ("[CURL.SetOptionUserName](CURLSetOptionUserName.md)"; curl; MQTT::Username );  
r = MBS ("[CURL.SetOptionPassword](CURLSetOptionPassword.md)"; curl; MQTT::Password );  
//   
// send request now  
result = MBS ("CURL.Perform"; curl);  
//   
// for checking error details  
$$debugLog = MBS ("[CURL.GetDebugMessages](CURLGetDebugMessages.md)"; curl; "UTF-8");  
$$output = MBS ("[CURL.GetResultAsText](CURLGetResultAsText.md)"; curl; "UTF-8");  
//   
r = MBS ("[CURL.Release](CURLRelease.md)"; curl)\]; result)  
### See also

- [CURL.UseSystemCertificates](CURLUseSystemCertificates.md)
- [CURL.WebSocketSend](CURLWebSocketSend.md)
- [Folders.System](FoldersSystem.md)
- [Folders.SystemTemporary](FoldersSystemTemporary.md)
- [GMImage.Scale](GMImageScale.md)
- [Hash.Digest](HashDigest.md)
- [JSON.Parse](JSONParse.md)
- [Path.LastPathComponent](PathLastPathComponent.md)
- [Plugin.SetFunctions](PluginSetFunctions.md)
- [SendMail.PrepareCURL](SendMailPrepareCURL.md)

### Release notes

- **Version 15.0**
    - Changed functions returning CURL errors to mark this as error, so [IsError](https://www.mbsplugins.eu/IsError.shtml) function returns true. This affects [CURL.Perform](https://www.mbsplugins.eu/CURLPerform.shtml), [CURL.FormClear](https://www.mbsplugins.eu/CURLFormClear.shtml), [CURL.FormFinish](https://www.mbsplugins.eu/CURLFormFinish.shtml), [CURL.Upkeep](https://www.mbsplugins.eu/CURLUpkeep.shtml), [CURL.SendText](https://www.mbsplugins.eu/CURLSendText.shtml), [CURL.SendData](https://www.mbsplugins.eu/CURLSendData.shtml), [CURL.PerformAsync](https://www.mbsplugins.eu/CURLPerformAsync.shtml), [CURL.WebSocketSend](https://www.mbsplugins.eu/CURLWebSocketSend.shtml), [CURL.WebSocketReceive](https://www.mbsplugins.eu/CURLWebSocketReceive.shtml), CURL.SetSocketNonBlocking, CURL.SetSocketNonBlocking, [SendMail.PrepareCURL](https://www.mbsplugins.eu/SendMailPrepareCURL.shtml) and various CURL.SetOption functions.
- **Version 11.4**
    - Added thread pool for Windows for multithreaded functions like [CURL.PerformInBackground](https://www.mbsplugins.eu/CURLPerformInBackground.shtml).
- **Version 9.0**
    - Improved error message text for [CURL.Perform](http://www.mbsplugins.eu/CURLPerform.shtml) calls.

### Example Databases

- [CURL/Amazon S3/Amazon S3 Buckets](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Amazon%20S3/Amazon%20S3%20Buckets.shtml#1ScriptAnchor_)
- [CURL/Amazon S3/Amazon S3 Upload Picture](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Amazon%20S3/Amazon%20S3%20Upload%20Picture.shtml#3ScriptAnchor_)
- [CURL/Email/Email Client](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/Email%20Client.shtml#3ScriptAnchor_)
- [CURL/Email/IMAP Email List](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/Email/IMAP%20Email%20List.shtml#1ScriptAnchor_)
- [CURL/FTP/CURL FTP Upload from file with Progress](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/FTP/CURL%20FTP%20Upload%20from%20file%20with%20Progress.shtml#2ScriptAnchor_)
- [CURL/WebServices/Swiss Post Addresscheck V4-02-00](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/WebServices/Swiss%20Post%20Addresscheck%20V4-02-00.shtml#1ScriptAnchor_)
- [CURL/WebServices/TinyURL](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/WebServices/TinyURL.shtml#1ScriptAnchor_)
- [CURL/WebServices/WeatherBit.io test](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/WebServices/WeatherBit.io%20test.shtml#1ScriptAnchor_)
- [CURL/WebViewer Download Images with CURL](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/WebViewer%20Download%20Images%20with%20CURL.shtml#1ScriptAnchor_)
- [WebHook/WebHook Chat/WebHook Chat](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/WebHook/WebHook%20Chat/WebHook%20Chat.shtml#4ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin 16.2 News](https://www.mbsplugins.de/archive/2026-05-20/MBS_FileMaker_Plugin_162_News/monkeybreadsoftware_blog_filemaker)
- [IMAP Upload Flags](https://www.mbsplugins.de/archive/2025-06-17/IMAP_Upload_Flags/monkeybreadsoftware_blog_filemaker)
- [Using Gmail with oAuth2 for SMTP with MBS Plugin](https://www.mbsplugins.de/archive/2025-05-08/Using_Gmail_with_oAuth2_for_SM/monkeybreadsoftware_blog_filemaker)
- [Send SMS with Amazon web service](https://www.mbsplugins.de/archive/2025-01-20/Send_SMS_with_Amazon_web_servi/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Advent calendar - Door 12 - Sending Mails](https://www.mbsplugins.de/archive/2024-12-12/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [Adding ChatGPT to the ScriptWorkspace context menu](https://www.mbsplugins.de/archive/2024-09-18/Adding_ChatGPT_to_the_ScriptWo/monkeybreadsoftware_blog_filemaker)
- [MQTT in FileMaker](https://www.mbsplugins.de/archive/2024-06-25/MQTT_in_FileMaker/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin Advent calendar: 21 - SendMail](https://www.mbsplugins.de/archive/2023-12-21/MBS_Plugin_Advent_calendar_21_/monkeybreadsoftware_blog_filemaker)
- [Parallel network transfers with MBS Plugin](https://www.mbsplugins.de/archive/2023-12-18/Parallel_network_transfers_wit/monkeybreadsoftware_blog_filemaker)
- [How long do you wait for Insert From URL to finish?](https://www.mbsplugins.de/archive/2023-10-10/How_long_do_you_wait_for_Inser/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 2/2025, Seite 24](https://filemaker-magazin.de/neuigkeit/4286-Appetithappen-FMM_202502)
- [Ausgabe 2/2025, Seite 22](https://filemaker-magazin.de/neuigkeit/4286-Appetithappen-FMM_202502)
- [Ausgabe 6/2024, Seite 38 bis 39](https://filemaker-magazin.de/neuigkeit/4277-Appetithappen-FMM_202406)
- [Ausgabe 6/2021, Seite 23](https://filemaker-magazin.de/neuigkeit/4165-Appetithappen-FMM_202106)
- [Ausgabe 4/2016, Seite 19 bis 20](https://filemaker-magazin.de/neuigkeit/3876-Appetithappen-FMM_201604)
- [Ausgabe 5/2014, Seite 26](https://filemaker-magazin.de/neuigkeit/3759-Appetithappen-FMM_201405)

This function checks for a license.

Created 18th August 2014 , last changed 10th November 2025

  
[CURL.Options](CURLOptions.md) - [CURL.PerformAsync](CURLPerformAsync.md)

[HTML Version](CURLPerform.shtml)