How to send Talk message from shellscript via curl?

As I did not find an occ subcommand to handle messages from within a shellscript I tried curl to get this done.

As this is my first time using webapi maybe I did not get all facts I need.

So I’m asking for help here.

As I read in https://nextcloud-talk.readthedocs.io/en/turn_doc/chat/ the base endpoint to talk is /ocs/v2.php/apps/spreed/api/v1 and before sending a message I need the token of the conversation I want to post a message.

So I tried the following commandline (masked):

 curl --user <myuser>:<mypass>   'https://tcloud.mydomain.org/ocs/v2.php/apps/spreed/api/v1/room' -H  "OCS-APIRequest: true"

that gave me the following result:

<?xml version="1.0"?>
<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>

What am I doing wrong here ?

1 Like

you are missing some required attributes… this is how it works for me:

curl -H "Content-Type: application/json" -H "Accept: application/json" -H "OCS-APIRequest: true" -v -u {user:password} -d '{"token": "{talk_conversationid}", "message":"test from linux"}' https://{mycloud.tld}/ocs/v2.php/apps/spreed/api/v1/chat/{talk_conversationid}

user:password could be “application password” for 2FA enabled users. I created a dedicated user for talk messages, enabled 2FA for this user and created app password without files access to reduce possible attack vector.

credits:

https://benedikt-merz.de/Blog/?p=945

Hi wwe, thank you for the tip it works now !

1 Like