webhooks via rest api

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • i have the 30.0.5 version installed
  • Operating system and version (e.g., Ubuntu 24.04):
    • debian 12 bookworm
  • Web server and version (e.g, Apache 2.4.25):
    • nginx 1.22
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • same as webserver
  • PHP version (e.g, 8.3):
    • php 8.2.20
  • Is this the first time you’ve seen this error? (Yes / No):
    • yes
  • When did this problem seem to first start?
    • the webhook feature was introduce in 30.0.1
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • i guess bare metal
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • no

Summary of the issue you are facing:

i am trying to create a webhook via the rest api endpoint ( https://example.com/ocs/v2.php/apps/webhook_listeners/api/v1/webhooks)

i keep getting the 500er internal server error that my httpMethod is null even tho it is set in my json payload

i also double checked the documentation for the request payload here:
https://docs.nextcloud.com/server/latest/developer_manual/_static/openapi.html#/operations/webhook_listeners-webhooks-create

Steps to replicate it (hint: details matter!):

First i just tried to verify that i can authenticate and read from the api

curl -X GET -H "Content-Type: application/json" -H "OCS-APIRequest: true" -u "admin:xxxxx" https://example.com/ocs/v2.php/apps/webhook_listeners/api/v1/webhooks

returns this
<?xml version="1.0"?>
<ocs>
 <meta>
  <status>ok</status>
  <statuscode>200</statuscode>
  <message>OK</message>
 </meta>
 <data/>
</ocs>

here is the curl command to post to the rest api:

curl  -H "Content-Type: application/json" -H "OCS-APIRequest: true" -u "admin:xxxx" "https://example.com/ocs/v2.php/apps/webhook_listeners/api/v1/webhooks" -d @tmp/webhook.json 
<?xml version="1.0"?>
<ocs>
 <meta>
  <status>failure</status>
  <statuscode>500</statuscode>
  <message>Internal Server Error
</message>
 </meta>
 <data/>
</ocs>

contents of the webhook.json

{
  "httpMethod": "POST",
  "uri": "https://webhook.example.com/flows/trigger/94b2fd27-d517-4b6f-861f-d5b1b6b4d884",
  "event": "OCP\Files\Events\Node\NodeReadEvent"
}


### Log entries

#### Nextcloud

{“reqId”:“cxOOBOO5W1gR1aZJbSWv”,“level”:3,“time”:“2025-01-24T14:50:40+00:00”,“remoteAddr”:“1.1.1.1”,“user”:“admin”,“app”:“no app in context”,“method”:“POST”,“url”:“/ocs/v2.php/apps/webhook_listeners/api/v1/webhooks”,“message”:“OCA\WebhookListeners\Controller\W
ebhooksController::create(): Argument #1 ($httpMethod) must be of type string, null given, called in /var/www/web/nextcloud/lib/private/AppFramework/Http/Dispatcher.php on line 208 in file ‘/var/www/web/nextcloud/apps/webhook_listeners/lib/Controller/WebhooksController.php’ l
ine 129”,“userAgent”:“curl/8.5.0”,“version”:“30.0.5.1”,“exception”:{“Exception”:“Exception”,“Message”:“OCA\WebhookListeners\Controller\WebhooksController::create(): Argument #1 ($httpMethod) must be of type string, null given, called in /var/www/web/nextcloud/lib/private/A
ppFramework/Http/Dispatcher.php on line 208 in file ‘/var/www/web/nextcloud/apps/webhook_listeners/lib/Controller/WebhooksController.php’ line 129”,“Code”:0,“Trace”:[{“file”:“/var/www/web/nextcloud/lib/private/AppFramework/App.php”,“line”:161,“function”:“dispatch”,“class”:“OC
\AppFramework\Http\Dispatcher”,“type”:“->”},{“file”:“/var/www/web/nextcloud/lib/private/Route/Router.php”,“line”:302,“function”:“main”,“class”:“OC\AppFramework\App”,“type”:“::”},{“file”:“/var/www/web/nextcloud/ocs/v1.php”,“line”:43,“function”:“match”,“class”:“OC\Route\
Router”,“type”:“->”},{“file”:“/var/www/web/nextcloud/ocs/v2.php”,“line”:7,“args”:[“/var/www/web/nextcloud/ocs/v1.php”],“function”:“require_once”}],“File”:“/var/www/web/nextcloud/lib/private/AppFramework/Http/Dispatcher.php”,“Line”:146,“Previous”:{“Exception”:“TypeError”,“Mess
age”:“OCA\WebhookListeners\Controller\WebhooksController::create(): Argument #1 ($httpMethod) must be of type string, null given, called in /var/www/web/nextcloud/lib/private/AppFramework/Http/Dispatcher.php on line 208”,“Code”:0,“Trace”:[{“file”:“/var/www/web/nextcloud/li
b/private/AppFramework/Http/Dispatcher.php”,“line”:208,“function”:“create”,“class”:“OCA\WebhookListeners\Controller\WebhooksController”,“type”:“->”,“args”:[“*** sensitive parameters replaced ***”]},{“file”:“/var/www/web/nextcloud/lib/private/AppFramework/Http/Dispatcher.ph
p”,“line”:114,“function”:“executeController”,“class”:“OC\AppFramework\Http\Dispatcher”,“type”:“->”},{“file”:“/var/www/web/nextcloud/lib/private/AppFramework/App.php”,“line”:161,“function”:“dispatch”,“class”:“OC\AppFramework\Http\Dispatcher”,“type”:“->”},{“file”:“/var/ww
w/web/nextcloud/lib/private/Route/Router.php”,“line”:302,“function”:“main”,“class”:“OC\AppFramework\App”,“type”:“::”},{“file”:“/var/www/web/nextcloud/ocs/v1.php”,“line”:43,“function”:“match”,“class”:“OC\Route\Router”,“type”:“->”},{“file”:“/var/www/web/nextcloud/ocs/v2.php
“,“line”:7,“args”:[”/var/www/web/nextcloud/ocs/v1.php”],“function”:“require_once”}],“File”:“/var/www/web/nextcloud/apps/webhook_listeners/lib/Controller/WebhooksController.php”,“Line”:129},“message”:“OCA\WebhookListeners\Controller\WebhooksController::create(): Argument #1
($httpMethod) must be of type string, null given, called in /var/www/web/nextcloud/lib/private/AppFramework/Http/Dispatcher.php on line 208 in file ‘/var/www/web/nextcloud/apps/webhook_listeners/lib/Controller/WebhooksController.php’ line 129”,“exception”:{},“CustomMessage”:
“OCA\WebhookListeners\Controller\WebhooksController::create(): Argument #1 ($httpMethod) must be of type string, null given, called in /var/www/web/nextcloud/lib/private/AppFramework/Http/Dispatcher.php on line 208 in file ‘/var/www/web/nextcloud/apps/webhook_listeners/lib
/Controller/WebhooksController.php’ line 129”}}


#### Web server / Reverse Proxy

The output of your Apache/nginx/system log in `/var/log/____`:

None same as mentioned above



### Configuration
 
#### Nextcloud

The output of `occ config:list system` or similar is best, but, if not possible, the contents of your `config.php` file from `/path/to/nextcloud` is fine (make sure to remove any identifiable information!):

{
“system”: {
“instanceid”: “REMOVED SENSITIVE VALUE”,
“debug”: false,
“passwordsalt”: “REMOVED SENSITIVE VALUE”,
“secret”: “REMOVED SENSITIVE VALUE”,
“trusted_domains”: [
example.com
],
“datadirectory”: “REMOVED SENSITIVE VALUE”,
“overwrite.cli.url”: “https://example.com”,
“dbtype”: “mysql”,
“version”: “30.0.5.1”,
“dbname”: “REMOVED SENSITIVE VALUE”,
“dbhost”: “REMOVED SENSITIVE VALUE”,
“dbport”: “”,
“dbtableprefix”: “oc_”,
“dbuser”: “REMOVED SENSITIVE VALUE”,
“dbpassword”: “REMOVED SENSITIVE VALUE”,
“installed”: true,
“theme”: “”,
“loglevel”: 0,
“maintenance”: false,
“ldapProviderFactory”: “\OCA\User_LDAP\LDAPProviderFactory”,
“mail_smtpmode”: “smtp”,
“mail_smtpauthtype”: “PLAIN”,
“mail_from_address”: “REMOVED SENSITIVE VALUE”,
“mail_smtphost”: “REMOVED SENSITIVE VALUE”,
“mail_smtpport”: “587”,
“mail_domain”: “REMOVED SENSITIVE VALUE”,
“memcache.local”: “\OC\Memcache\APCu”,
“memcache.distributed”: “\OC\Memcache\Memcached”,
“memcache.locking”: “\OC\Memcache\Memcached”,
“memcached_servers”: [
[
“localhost”,
11211
]
],
“onlyoffice”: {
“jwt_secret”: “REMOVED SENSITIVE VALUE”,
“jwt_header”: “AuthorizationJwt”
},
“encryption.legacy_format_support”: false,
“encryption.key_storage_migrated”: false,
“mail_sendmailmode”: “smtp”,
“app_install_overwrite”: [
“files_frommail”,
“mindmap_app”,
“flow_notifications”,
“ocr”
],
“mysql.utf8mb4”: true,
“maintenance_window_start”: 1,
“default_phone_region”: “DE”,
“mail_smtpauth”: 1,
“mail_smtpname”: “REMOVED SENSITIVE VALUE”,
“mail_smtppassword”: “REMOVED SENSITIVE VALUE”,
“updater.secret”: “REMOVED SENSITIVE VALUE
}
}


#### Apps

The output of `occ app:list` (if possible).

Enabled:

  • activity: 3.0.0
  • admin_audit: 1.20.0
  • analytics: 5.2.4
  • app_api: 4.0.5
  • appointments: 2.3.5
  • approval: 2.1.0
  • calendar: 5.0.9
  • calendar_resource_management: 0.8.0
  • circles: 30.0.0
  • cloud_federation_api: 1.13.0
  • comments: 1.20.1
  • contacts: 6.1.3
  • contactsinteraction: 1.11.0
  • cookbook: 0.11.2
  • dashboard: 7.10.0
  • dav: 1.31.1
  • deck: 1.14.3
  • drawio: 3.0.3
  • encryption: 2.18.0
  • event_update_notification: 2.5.0
  • federatedfilesharing: 1.20.0
  • federation: 1.20.0
  • files: 2.2.0
  • files_confidential: 3.1.0
  • files_downloadlimit: 3.0.0
  • files_pdfviewer: 3.0.0
  • files_reminders: 1.3.0
  • files_sharing: 1.22.0
  • files_trashbin: 1.20.1
  • files_versions: 1.23.0
  • firstrunwizard: 3.0.0
  • flow_notifications: 1.10.1
  • forms: 4.3.5
  • google_synchronization: 3.0.0
  • integration_google: 3.1.1
  • logreader: 3.0.0
  • lookup_server_connector: 1.18.0
  • mail: 4.1.2
  • nextcloud_announcements: 2.0.0
  • notes: 4.11.0
  • notifications: 3.0.0
  • oauth2: 1.18.1
  • onlyoffice: 9.5.0
  • password_policy: 2.0.0
  • photos: 3.0.2
  • polls: 7.2.9
  • privacy: 2.0.0
  • provisioning_api: 1.20.0
  • recommendations: 3.0.0
  • related_resources: 1.5.0
  • riotchat: 0.18.7
  • serverinfo: 2.0.0
  • settings: 1.13.0
  • sharebymail: 1.20.0
  • sociallogin: 5.8.2
  • support: 2.0.0
  • survey_client: 2.0.0
  • systemtags: 1.20.0
  • tasks: 0.16.1
  • text: 4.1.0
  • theming: 2.5.0
  • timemanager: 0.3.16
  • twofactor_backupcodes: 1.19.0
  • twofactor_nextcloud_notification: 4.0.0
  • twofactor_totp: 12.0.0-dev
  • updatenotification: 1.20.0
  • user_ldap: 1.21.0
  • user_status: 1.10.0
  • viewer: 3.0.0
  • weather_status: 1.10.0
  • webhook_listeners: 1.1.0-dev
  • whiteboard: 1.0.5
  • workflow_ocr: 1.30.1
  • workflow_pdf_converter: 1.15.1
  • workflow_script: 1.15.0
  • workflowengine: 2.12.0