SharePoint GetFileByServerRelativeUrl problems with comment text

LaFetra, Ross 1 Reputation point

I am using Python's SharePlum, and am having problems with checking in a file with comments. I can successfully checkin a file with comments, but there appears to be restrictions on the comments that are not present when using SharePoint through a browser. I've traced this through Python to the url used, and all seems well, but something on the SharePoint side is rejecting it. I cannot find much documentation about what can appear in the comment text, I have found something that says the comment text is limited to 1023 characters, but nothing about restricted characters in comments, and the browser interface allows those characters. Sharepoint version is Office365 I think.

The python code
generates the url'/sites/mysite/Shared%20Documents/myfolder/HelloWorld.txt')/CheckIn(comment='leg<al',checkintype=0)

and fails with the message:

Traceback (most recent call last):
File "C:\Users\myuser\Anaconda3\lib\site-packages\shareplum\", line 18, in post
File "C:\Users\myuser\Anaconda3\lib\site-packages\requests\", line 953, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url:\_api/web/GetFileByServerRelativeUrl('/sites/mysite/Shared%20Documents/myfolder/HelloWorld.txt')/CheckIn(comment='leg%3Cal',checkintype=0)

The python code (just missing the '<' in the string)
generates the url\_api/web/GetFileByServerRelativeUrl('/sites/mysite/Shared%20Documents/myfolder/HelloWorld.txt')/CheckIn(comment='legal',checkintype=0)

and works.

Again, I have no problems with the '<' in the comments when I check it in the browser. I can reproduce this on 2 of 2 machines I've tried. There are two characters I am primarily interested in: > and newline. Any hints on how to do this?

A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,874 questions
0 comments No comments
{count} votes