CURL.SendText
-------------

Sends raw data with text over a connection.

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

MBS( "CURL.SendText"; curl; Text { ; Encoding } ) 

**MBS**( **"CURL.SendText";** /\* Sends raw data with text over a connection. \*/  
**$curl**; /\* The CURL session handle. \*/   
**$Text**; /\* The text to send. \*/   
**$Encoding**) /\* Optional; The text encoding for text parameter.   
Default is UTF-8.e.g. "UTF8" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| curl | The CURL session handle. | $curl |  |
| Text | The text to send. |  |  |
| Encoding | The text encoding for text parameter.    Default is UTF-8.   Possible encoding names: ANSI, ISO-8859-1, Latin1, Mac, Native, UTF-8, DOS, Hex, Base64 or Windows. More listed in the [FAQ](https://www.monkeybreadsoftware.com/filemaker/faq.shtml). | "UTF8" | Optional |

### Result

Returns OK or error.

### Description

Sends raw data with text over a connection.  
This function sends arbitrary data over the established connection. You may use it together with ReceiveData to implement custom protocols using libcurl. This functionality can be particularly useful if you use proxies and/or SSL encryption: libcurl will take care of proxy negotiation and connection set-up.  
  
Provide the data to send via parameter. We return the number of bytes sent.  
  
To establish the connection, use [CURL.SetOptionConnectOnly](CURLSetOptionConnectOnly.md) with value 1 before calling [CURL.Perform](CURLPerform.md) function. Note that SendData will not work on connections that were created without this option.  
  
The call will return empty and set error to CURLE\_AGAIN (81) if it's not possible to send data right now - the socket is used in non-blocking mode internally. When CURLE\_AGAIN is returned, please wait.  
  
Furthermore if you wait on the socket and it tells you it's writable, SendData may return CURLE\_AGAIN if the only data that was sent was for internal SSL processing, and no other data could be sent.  
  
Please use [CURL.ErrorCode](CURLErrorCode.md) to query error after you used this function.  
### Examples

Send HTTP request:

 Set Variable \[$request ; Value:"GET / HTTP/1.1 ¶Host: www.monkeybreadsoftware.com¶¶" // must end with two empty lines \]  
Set Variable \[$request2 ; Value:MBS ( "[Text.ReplaceNewLine](TextReplaceNewLine.md)"; $request ; 3)\]  
Set Variable \[$r ; Value:MBS ( "CURL.SendText"; $curl ; $request2 ; "UTF-8")\]  
### See also

- [CURL.ErrorCode](CURLErrorCode.md)
- [CURL.Perform](CURLPerform.md)
- [CURL.SetOptionConnectOnly](CURLSetOptionConnectOnly.md)
- [Socket.SSL.Connect](SocketSSLConnect.md)
- [Socket.SSL.Initialize](SocketSSLInitialize.md)
- [Text.ReplaceNewLine](TextReplaceNewLine.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 7.2**
    - Added [CURL.ReceiveData](http://www.mbsplugins.eu/CURLReceiveData.shtml), [CURL.ReceiveText](http://www.mbsplugins.eu/CURLReceiveText.shtml), [CURL.SendData](http://www.mbsplugins.eu/CURLSendData.shtml) and [CURL.SendText](http://www.mbsplugins.eu/CURLSendText.shtml) to send data over a CURL connected socket.

### Example Databases

- [CURL/CURL Low Level Sockets](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/CURL/CURL%20Low%20Level%20Sockets.shtml#2ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 15.0pr9](https://www.mbsplugins.de/archive/2025-01-10/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [Socket changes for MBS FileMaker Plugin](https://www.mbsplugins.de/archive/2020-08-31/Socket_changes_for_MBS_FileMak/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 7.2pr1](https://www.mbsplugins.de/archive/2017-04-03/MBS_FileMaker_Plugin_version_7/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 27th March 2017 , last changed 4th March 2023

  
[CURL.SendData](CURLSendData.md) - [CURL.SetBatchDestinationPath](CURLSetBatchDestinationPath.md)

[HTML Version](CURLSendText.shtml)