Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin notifications via api not working since nextcloud 21 #877

Closed
fracarvic opened this issue Mar 1, 2021 · 16 comments · Fixed by #928
Closed

Admin notifications via api not working since nextcloud 21 #877

fracarvic opened this issue Mar 1, 2021 · 16 comments · Fixed by #928

Comments

@fracarvic
Copy link

Steps to reproduce

  1. send admin notification using curl:
    curl -H "OCS-APIREQUEST: true" -X POST https://admin:[email protected]/ocs/v2.php/apps/admin_notifications/api/v1/notifications/admin -d "shortMessage=short" -d "longMessage=long"

Expected behaviour

Return code 200 and notification sent.

Actual behaviour

Return code 404

<ocs>  
 <meta>  
  <status>failure</status> 
  <statuscode>404</statuscode> 
  <message>Invalid query, please check the syntax. API specifications are here:  http://www.freedesktop.org/wiki/Specifications/open-collaboration-services.
</message> 
 </meta> 
 <data/> 
</ocs>

This seems to happen to me since upgrading to nextcloud 21, in previous versions admin notificacions was working perfectly.
Notificacions via occ notification:generate are working ok.

Server configuration

Operating system:
kubernetes (kubeadm) node on Ubuntu server 20.10

Web server:
Apache/2.4.38 (Debian)
Database:
MariaDB 10.5.6
PHP version:
PHP/7.4.15
Nextcloud version: (see Nextcloud admin page)
21.0.0
Where did you install Nextcloud from:
Official docker image 21.0.0-apache
Signing status:

No errors have been found.

List of activated apps:

Enabled:
  - accessibility: 1.7.0
  - activity: 2.14.3
  - calendar: 2.1.3
  - cloud_federation_api: 1.4.0
  - comments: 1.11.0
  - contacts: 3.4.3
  - contactsinteraction: 1.2.0
  - dav: 1.17.1
  - federatedfilesharing: 1.11.0
  - federation: 1.11.0
  - files: 1.16.0
  - files_external: 1.12.0
  - files_fulltextsearch: 20.0.0
  - files_pdfviewer: 2.1.0
  - files_rightclick: 1.0.0
  - files_sharing: 1.13.1
  - files_trashbin: 1.11.0
  - files_versions: 1.14.0
  - files_videoplayer: 1.10.0
  - firstrunwizard: 2.10.0
  - fulltextsearch: 20.0.0
  - fulltextsearch_elasticsearch: 20.0.0
  - logreader: 2.6.0
  - lookup_server_connector: 1.9.0
  - news: 15.3.2
  - nextcloud_announcements: 1.10.0
  - notes: 4.0.2
  - notifications: 2.9.0
  - oauth2: 1.9.0
  - password_policy: 1.11.0
  - photos: 1.3.0
  - provisioning_api: 1.11.0
  - rainloop: 7.0.3
  - serverinfo: 1.11.0
  - settings: 1.3.0
  - sharebymail: 1.11.0
  - support: 1.4.0
  - survey_client: 1.9.0
  - systemtags: 1.11.0
  - text: 3.2.0
  - theming: 1.12.0
  - twofactor_backupcodes: 1.10.0
  - updatenotification: 1.11.0
  - user_saml: 4.1.0
  - user_status: 1.1.1
  - viewer: 1.5.0
  - weather_status: 1.1.0
  - workflowengine: 2.3.0
Disabled:
  - admin_audit
  - dashboard
  - encryption
  - privacy
  - recommendations
  - user_ldap

Nextcloud configuration:

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "***REMOVED SENSITIVE VALUE***",
            "***REMOVED SENSITIVE VALUE***",
            "***REMOVED SENSITIVE VALUE***"
        ],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "overwriteprotocol": "https",
        "overwrite.cli.url": "***REMOVED SENSITIVE VALUE***",
        "htaccess.RewriteBase": "\/",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "log_rotate_size": 10485760,
        "loglevel": 2,
        "dbtype": "mysql",
        "version": "21.0.0.18",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbtableprefix": "oc_",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "mysql.utf8mb4": true,
        "installed": true,
        "maintenance": false,
        "upgrade.disable-web": true,
        "data-fingerprint": "***REMOVED SENSITIVE VALUE***",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379,
            "dbindex": 2,
            "password": "***REMOVED SENSITIVE VALUE***"
        },
        "trashbin_retention_obligation": "auto,30",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "25",
        "mail_sendmailmode": "smtp",
        "app_install_overwrite": [
            "calendar",
            "fulltextsearch",
            "fulltextsearch_elasticsearch",
            "files_fulltextsearch",
            "rainloop"
        ],
        "updater.release.channel": "stable",
        "allow_local_remote_servers": "true",
        "default_phone_region": "ISO 3166-2:ES"
    }
}

Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...
user_saml

@nickvergessen
Copy link
Member

There should be an error in your log?

@fracarvic
Copy link
Author

Logs do not show any message.

@nickvergessen
Copy link
Member

Ah, in your url replace apps/admin_notifications with apps/notifications

@fracarvic
Copy link
Author

Ah, in your url replace apps/admin_notifications with apps/notifications

Just tried it and same errors, nothing in logs and 404 return code.

I have a script in my home automation system that send notifications using ocs/v2.php/apps/admin_notifications/api/v1/notifications/ and was working since nextcloud 21 upgrade, and docs says admin_notifications in url.

@nickvergessen
Copy link
Member

okay after checking again admin_notifications is right. not sure why you get a 404 though. there should be something in your nextcloud.log or apache access/error log, of the notifications app is disabled.

@fracarvic
Copy link
Author

Ok, if admin notifications are working with nextcloud 21, I will enable debugging and look deeper at the logs.

@mxsenay
Copy link

mxsenay commented Apr 14, 2021

@fracarvic Were you able to resolve your issue? I'm experiencing the same response with the exact REST API call with Nextcloud 21. I didn't have prior experience with older versions of Nextcloud, and if you resolved it, I would like to know.

@fracarvic
Copy link
Author

@fracarvic Were you able to resolve your issue? I'm experiencing the same response with the exact REST API call with Nextcloud 21. I didn't have prior experience with older versions of Nextcloud, and if you resolved it, I would like to know.

No, i can't solve it. I didn't see any relevant in logs. I upgrade to 21 (official docker hub image) and it doesn't work either.

@mxsenay
Copy link

mxsenay commented Apr 14, 2021

I'm also running Nextcloud 21 in Docker (Ubuntu Server). Do you have an option to reopen this issue? I think Nick closed it by mistake.

@fracarvic
Copy link
Author

I dont have the option to reopen the issue.

Maybe the problem does not occur in normal installs, only with docker, I don't know.

@nickvergessen
Copy link
Member

I'll retry tomorrow

@nickvergessen
Copy link
Member

Arg, sorry about this. I thought we have integration tests for this and my local installation only uses the occ command, so it worked for me. Turns out we didnt and the route was defined in another apps namespace which we prevent since 21. I made a PR at #928 you will have to patch it or wait for 21.0.2 and you also need to use a different URL now.

@fracarvic
Copy link
Author

Yeah, I manually patch routes.php and i'ts working using modified url.

Thanks.

@provokateurin
Copy link
Member

So I've been waiting for 21.0.2 to release and now I wanted to try again, but I still get 404. This is the exact command I'm using: curl -H "OCS-APIREQUEST: true" -X POST http://admin:password@localhost:8080/ocs/v2.php/apps/admin_notifications/api/v1/notifications/admin -d "shortMessage=short" -d "longMessage=long". At least from reading https://github.com/nextcloud/notifications/blob/master/docs/admin-notifications.md#http-request and this issue it should be correct, but it doesn't work.

@nickvergessen
Copy link
Member

No, your url is slightly wrong. Its

notifications/api/v1/admin_notifications/admin

But you have

admin_notifications/api/v1/notifications/admin

@provokateurin
Copy link
Member

Ah I got the version wrong. Sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants