Reputation: 721
I am using Python's requests module to post some data to my company's SharePoint site:
response = requests.post("https//my-sharepoint-site.com",
data={"myPost": "this is a test"},
auth=HttpNtlmAuth("\\MY_USER_NAME", MY_PASS))
The resulting post on my company's sharepoint site looks like:
myPost=this+is+a+test
How do I 1) remove "myPost=" and 2) stop the filling of white space with '+' ?
Note: I do not have access to the company's server-side application logic.
Another note: curl does not encode white spaces with '+'. The result of:
curl –f –v --ntlm –u MY_USER_NAME --data “this is a test” https://my-sharepoint-site.com
is:
this is a test
Upvotes: 1
Views: 1923
Reputation: 60987
You're passing a dict as the data
parameter, which means the dict is interpreted as key-value pairs to be encoded as application/x-url-encoded
. URL encoding (such as is used for GET requests) substitutes +
characters instead of %20
because that is the behavior of most browsers.
If you want to pass a POST body literally, you need to encode it into bytes yourself.
In your case, simply passing data="this is a test".encode("utf-8")
should give you the behavior you want.
Upvotes: 1