WebRequest.Send
---------------

Send custom answer.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [WebHook](component_WebHook.md) | [11.5](newinversion115.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "WebRequest.Send"; WebRequest; Text { ; Encoding } ) 

**MBS**( **"WebRequest.Send";** /\* Send custom answer. \*/  
**$WebRequest**; /\* The reference number of the web request. \*/   
**$Text**; /\* The text to send out.  
Should use CRLF as line endings and end with two CRLF. \*/   
**$Encoding**) /\* Optional; The text encoding for result.   
Default is UTF-8.e.g. "UTF8" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| WebRequest | The reference number of the web request. | $WebRequest |  |
| Text | The text to send out.   Should use CRLF as line endings and end with two CRLF. |  |  |
| Encoding | The text encoding for result.    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 number or error.

### Description

Send custom answer.  
This allows you to assemble a custom HTTP response and send it.  
The answer is sent above the connection to the other side where the request is coming from.  
  
Please make sure your HTTP response header uses CRLF as line endings and ends with two CRLF. Then you may send additional content like e.g. JSON data.  
  
Returns number of bytes sent on success.  
### Examples

Send HTTP response:

 Set Variable \[ $text ; Value: "HTTP/1.1 201 Tested¶Server: MyServer 1.0 ¶Connection: close¶Content-Length: 0¶¶" \]   
Set Variable \[ $text ; Value: MBS ( "[Text.ReplaceNewLine](TextReplaceNewLine.md)"; $Text ; 3 ) \]   
Set Variable \[ $r ; Value: MBS ("WebRequest.Send"; $WebRequest ; $text ; "UTF-8") \]  
Send RAW answer:

 Set Variable \[ $text ; Value: "Hello World!" &amp; Char(13) &amp; Char(10) \]   
Set Variable \[ $r ; Value: MBS ("WebRequest.Send"; $WebRequest ; $text ; "UTF-8") \]  
### See also

- [Text.ReplaceNewLine](TextReplaceNewLine.md)
- [WebHook.SetAutoAnswer](WebHookSetAutoAnswer.md)
- [WebHook.SetMode](WebHookSetMode.md)
- [WebRequest.List](WebRequestList.md)
- [WebRequest.SetTag](WebRequestSetTag.md)

### Example Databases

- [WebHook/Trigger script with Webhook/WebHook Listener](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/WebHook/Trigger%20script%20with%20Webhook/WebHook%20Listener.shtml#3ScriptAnchor_)
- [WebHook/WebHook to serve html](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/WebHook/WebHook%20to%20serve%20html.shtml#2ScriptAnchor_)
- [WebHook/WebHook](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/WebHook/WebHook.shtml#6ScriptAnchor_)

### Blog Entries

- [Trigger Scripts via WebHook](https://www.mbsplugins.de/archive/2022-12-08/Trigger_Scripts_via_WebHook/monkeybreadsoftware_blog_filemaker)
- [WebHook Introduction](https://www.mbsplugins.de/archive/2021-10-28/WebHook_Introduction/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 17th October 2021 , last changed 5th November 2021

  
[WebRequest.Release](WebRequestRelease.md) - [WebRequest.SetTag](WebRequestSetTag.md)

[HTML Version](WebRequestSend.shtml)