WebHook.SetMode
---------------

Sets mode flags.

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

MBS( "WebHook.SetMode"; WebHook; Mode ) 

**MBS**( **"WebHook.SetMode";** /\* Sets mode flags. \*/  
**$WebHook**; /\* The reference number of the web hook. \*/   
**$Mode**) /\* The new mode.e.g. 1+2 \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| WebHook | The reference number of the web hook. | $webhook |
| Mode | The new mode. | 1+2 |

### Result

Returns OK or error.

### Description

Sets mode flags.  
Pass 1 for keeping connection open.  
Pass 2 for accepting non HTTP connections, e.g. to accept notifications from devices like scales.  
  
If connection stays open, you can send a custom answer in the triggered script via [WebRequest.Send](WebRequestSend.md) function. Pass also empty text for [WebHook.SetAutoAnswer](WebHookSetAutoAnswer.md) to disable auto answering.  
  
The RAW connection option allows you to accept other data than HTTP requests. Use [WebRequest.GetRawData](WebRequestGetRawData.md) to read the data coming in. Use either [WebHook.SetAutoAnswer](WebHookSetAutoAnswer.md) to automatically send data or use flag 1 to also keep connection open to use [WebRequest.Send](WebRequestSend.md) function to send your answer.  
### Examples

Create web hook with keep connection:

 If \[ IsEmpty ( $$WebHooks ) \]   
 Set Variable \[ $$WebHooks ; Value: MBS ("[WebHook.Create](WebHookCreate.md)") \]   
 #   
 # enable keep open and disable auto answer, so we can send custom answer  
 Set Variable \[ $r ; Value: MBS ("[WebHook.SetAutoAnswer](WebHookSetAutoAnswer.md)"; $$Webhooks ; ""; "UTF-8") \]   
 Set Variable \[ $r ; Value: MBS ("WebHook.SetMode"; $$WebHooks ; 1) \]   
 #   
 Set Variable \[ $r ; Value: MBS ("[WebHook.Listen](WebHookListen.md)"; $$WebHooks ; WebHook::Server Port) \]   
 Set Variable \[ $r ; Value: MBS ("[WebHook.SetScript](WebHookSetScript.md)"; $$WebHooks ; Get(FileName); "WebHookReceived With KeepOpen") \]   
 Set Field \[ WebHook::Server Webhook ; $$WebHooks \]   
End If  
Start a RAW hook:

 If \[ IsEmpty ( $$WebHooks ) \]   
 Set Variable \[ $$WebHooks ; Value: MBS ("[WebHook.Create](WebHookCreate.md)") \]   
 #   
 # enable keep open and disable auto answer, so we can send custom answer  
 Set Variable \[ $r ; Value: MBS ("[WebHook.SetAutoAnswer](WebHookSetAutoAnswer.md)"; $$Webhooks ; ""; "UTF-8") \]   
 Set Variable \[ $r ; Value: MBS ("WebHook.SetMode"; $$WebHooks ; 2+1) \]   
 #   
 Set Variable \[ $r ; Value: MBS ("[WebHook.Listen](WebHookListen.md)"; $$WebHooks ; WebHook::Server Port) \]   
 Set Variable \[ $r ; Value: MBS ("[WebHook.SetScript](WebHookSetScript.md)"; $$WebHooks ; Get(FileName); "WebHookReceived With RAW Mode") \]   
 Set Field \[ WebHook::Server Webhook ; $$WebHooks \]   
End If  
### See also

- [WebHook.Create](WebHookCreate.md)
- [WebHook.GetMode](WebHookGetMode.md)
- [WebHook.GetPort](WebHookGetPort.md)
- [WebHook.List](WebHookList.md)
- [WebHook.Listen](WebHookListen.md)
- [WebHook.SetScript](WebHookSetScript.md)
- [WebHook.SetSSL](WebHookSetSSL.md)
- [WebHook.SetTag](WebHookSetTag.md)
- [WebRequest.GetRawData](WebRequestGetRawData.md)
- [WebRequest.Send](WebRequestSend.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#1ScriptAnchor_)
- [WebHook/WebHook to serve html](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/WebHook/WebHook%20to%20serve%20html.shtml#1ScriptAnchor_)
- [WebHook/WebHook](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/WebHook/WebHook.shtml#5ScriptAnchor_)

### 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 18th October 2021

  
[WebHook.SetMaximumRequestSize](WebHookSetMaximumRequestSize.md) - [WebHook.SetSSL](WebHookSetSSL.md)

[HTML Version](WebHookSetMode.shtml)