Nc_py_api send message error

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Some useful links to gather information about your Nextcloud Talk installation:
Information about Signaling server: /index.php/index.php/settings/admin/talk#signaling_server
Information about TURN server: /index.php/settings/admin/talk#turn_server
Information about STUN server: /index.php/settings/admin/talk#stun_server

Nextcloud version (eg, 24.0.1): Nextcloud Hub 6 (27.1.4)
Talk Server version (eg, 14.0.2): 17.1.3
Custom Signaling server configured: no
Custom TURN server configured: no
Custom STUN server configured: no

In case the web version of Nextcloud Talk is involved:
Operating system (eg, Windows/Ubuntu/…): Ubuntu 22.04.1 LTS
Browser name and version (eg, Chrome v101): brave 160

In case mobile Nextcloud Talk apps are involved: no
Talk iOS version (eg, 14.0.2): x
Talk Android version (eg, 14.0.2): x

The issue you are facing:
Using the nc_py_api when I send message i have 500 error

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

from nc_py_api import *
nc = Nextcloud(nextcloud_url=“http://192.168.x.x”, npa_nc_cert=False, nc_auth_user=“xxx”, nc_auth_pass=“xxxx”)
all_conversations = nc.talk.get_user_conversations()
for conversation in all_conversations:
nc.talk.send_message(“hello world”, conversation)

The output of your Nextcloud log in Admin > Logging or errors in nextcloud.log in /var/www/:

Exception: OCA\Talk\Controller\ChatController::receiveMessages(): Argument #1 ($lookIntoFuture) must be of type int, null given, called in /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php on line 230 in file '/var/www/nextcloud/apps/spreed/lib/Controller/ChatController.php' line 409
/var/www/nextcloud/lib/private/AppFramework/App.php - line 183:

OC\AppFramework\Http\Dispatcher->dispatch()

/var/www/nextcloud/lib/private/Route/Router.php - line 315:

OC\AppFramework\App::main()

/var/www/nextcloud/ocs/v1.php - line 64:

OC\Route\Router->match()

/var/www/nextcloud/ocs/v2.php - line 23:

require_once("/var/www/nextcloud/ocs/v1.php")

Caused by TypeError: OCA\Talk\Controller\ChatController::receiveMessages(): Argument #1 ($lookIntoFuture) must be of type int, null given, called in /var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php on line 230
/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 230:

OCA\Talk\Controller\ChatController->receiveMessages()

/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php - line 137:

OC\AppFramework\Http\Dispatcher->executeController()

/var/www/nextcloud/lib/private/AppFramework/App.php - line 183:

OC\AppFramework\Http\Dispatcher->dispatch()

/var/www/nextcloud/lib/private/Route/Router.php - line 315:

OC\AppFramework\App::main()

/var/www/nextcloud/ocs/v1.php - line 64:

OC\Route\Router->match()

/var/www/nextcloud/ocs/v2.php - line 23:

require_once("/var/www/nextcloud/ocs/v1.php")

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

nothing related

Your browser log if relevant (pyhon output):

Traceback (most recent call last):
  File "/home/xxx/bots/testbot/hi.py", line 16, in <module>
    nc.talk.send_message("hello world", conversation)
  File "/home/xxx/.local/lib/python3.11/site-packages/nc_py_api/_talk_api.py", line 261, in send_message
    r = self._session.ocs("POST", self._ep_base + f"/api/v1/chat/{token}", json=params)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxx/.local/lib/python3.11/site-packages/nc_py_api/_session.py", line 216, in ocs
    return self._ocs(method, f"{quote(path)}?{urlencode(params, True)}", headers, data=data_bytes, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxx/.local/lib/python3.11/site-packages/nc_py_api/_session.py", line 236, in _ocs
    check_error(response.status_code, info)
  File "/home/xxx/.local/lib/python3.11/site-packages/nc_py_api/_exceptions.py", line 62, in check_error
    raise NextcloudException(code, reason=codes(code).phrase, info=info)
nc_py_api._exceptions.NextcloudException: [500] Internal Server Error <request: method=POST, url=http://192.168.x.x/ocs/v2.php/apps/spreed/api/v1/chat/xxxxx?format=json>

Sorry I just see I was the http link and not https ^^’