Skip to content

Sharepoint API get_comments() method issues POST instead of GET #956

Closed
@bizzinho

Description

@bizzinho

When trying to run get_comments() via something like

l_items[216].get_comments().execute_query()

one obtains the error

ClientRequestException: ('-1, Microsoft.SharePoint.Client.InvalidClientQueryException', "A node of type 'EndOfInput' was read from the JSON reader when trying to read the start of an entry. A 'StartObject' node was expected.", "400 Client Error: Bad Request for url: https://url/_api/Web/lists/GetByTitle('ListTitle')/items(216)/GetComments()")

is produced.

The issue seems to be a wrong request.method that is ultimately being used in execute_query(). The following patchwork fix resolves the issue, though it is clearly not tackling the root cause:

   def execute_query(self, query):
        # type: (ClientQuery) -> None
        """Submits a pending request to the server"""
        try:
            request = self.build_request(query)
            # fix request.method on the fly
            if "getcomments" in request.url.lower():
                request.method = "GET"
            response = self.execute_request_direct(request)
            self.process_response(response, query)
            self.afterExecute.notify(response)
        except HTTPError as e:
            raise ClientRequestException(*e.args, response=e.response)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions