Skip to content

error posting chat message via api - TypeError: XMLWriter::writeElement(): Argument #2 ($content) must be of type ?string, stdClass given at /var/www/html/lib/private/AppFramework/OCS/BaseResponse.php#148 #7952

@meonkeys

Description

@meonkeys

I post messages from a Python script to a chat on my Nextcloud server using the api.

I'm seeing a new error every time I post a message. The error shows up in my main Nextcloud server log, and it seems to have started when I upgraded the Talk app to version 14.0.5 on Thu Sep 15.

The error is: TypeError: XMLWriter::writeElement(): Argument #2 ($content) must be of type ?string, stdClass given at /var/www/html/lib/private/AppFramework/OCS/BaseResponse.php#148.

Here's the full error message from my nextcloud.log file (redacted and formatted for readability):

{
    "reqId": "redacted",
    "level": 3,
    "time": "2022-09-15T20:20:04+00:00",
    "remoteAddr": "redacted",
    "user": "redacted",
    "app": "PHP",
    "method": "POST",
    "url": "/ocs/v2.php/apps/spreed/api/v1/chat/redacted",
    "message": "TypeError: XMLWriter::writeElement(): Argument #2 ($content) must be of type ?string, stdClass given at /var/www/html/lib/private/AppFramework/OCS/BaseResponse.php#148",
    "userAgent": "python-requests/2.20.0",
    "version": "24.0.5.1",
    "data": {
        "app": "PHP"
    }
}

The message still shows up in the chat room despite the logged error.

My Nextcloud server is running in a Docker container from a 24.0.5-apache image.

On the client side, I get an HTTP 200 response with nothing in the body. I'm using code almost exactly like this to send messages and my code hasn't changed since Dec 2021.

Hopefully this is enough info to point to the culprit. I'm happy to provide more debugging information or a stand-alone repro if necessary.

Note the response status code is 200 but the docs say it should be 201.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions