Skip to content

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

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

Open
bizzinho opened this issue Apr 11, 2025 · 0 comments
Open

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

bizzinho opened this issue Apr 11, 2025 · 0 comments
Labels

Comments

@bizzinho
Copy link

bizzinho commented Apr 11, 2025

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)
@vgrem vgrem added the bug label Apr 11, 2025
vgrem added a commit that referenced this issue Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants