splunk / splunk-sdk-python

Splunk Software Development Kit for Python
http://dev.splunk.com
Apache License 2.0
698 stars 370 forks source link

binding.py // Context.request URL-encodes request body #577

Open moschi opened 5 months ago

moschi commented 5 months ago

Bug description We have a REST endpoint to update a datastructure that requires the use of the HTTP PUT method. We're using request from the Context class to send a request to that endpoint. On binding.py#L876, the _encode method is called, whose result is used to overwrite the original body parameter of the method. This causes the request-body to be url-encoded and url-formatted.

Steps to reproduce the behavior:

Send a HTTP PUT request with a JSON body to an endpoint, using the request method of the Context class.

Expected behavior

The request method correctly escapes a JSON body, or provides instructions on how to call it to prevent the URL-encoding.

Logs or Screenshots

Currently, our REST endpoint receives a payload similar to this:

event=%7B%27_key%27%3A+%2766548f65179fc9792600b193%27%2C+%27tenant_uid%27%3A+%27default%27%7D&update_objects=%7B%27attribute%27%3A+status%2C+%27value%27%3A+%2766436bc36265a3697e049fe6%27%7D&comment=Updated

which does not decode to a valid JSON structure:

event={'_key':+'66548f65179fc9792600b193',+'tenant_uid':+'default'}&update_objects={'attribute':+status,+'value':+'66436bc36265a3697e049fe6'}&comment=Updated

Splunk:

SDK:

seiimonn commented 3 months ago

Hi team!

Could we please get a response on this? It seems to be a minor fix!

Thank you!