Skip to content

Fix HTTP 400 errors for certain post requests #208

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 9 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,28 +282,16 @@ If you would like to contribute to the SDK, go here for more information:

### Support

1. You will be granted support if you or your company are already covered
under an existing maintenance/support agreement. Send an email to
_support@splunk.com_ and include "Splunk SDK for Python" in the subject line.

2. If you are not covered under an existing maintenance/support agreement, you
can find help through the broader community at:

<ul>
<li><a href='http://splunk-base.splunk.com/answers/'>Splunk Answers</a> (use
the <b>sdk</b>, <b>java</b>, <b>python</b>, and <b>javascript</b> tags to
identify your questions)</li>
<li><a href='http://groups.google.com/group/splunkdev'>Splunkdev Google
Group</a></li>
</ul>
3. Splunk will NOT provide support for SDKs if the core library (the
code in the <b>/splunklib</b> directory) has been modified. If you modify an
SDK and want support, you can find help through the broader community and
Splunk answers (see above). We would also like to know why you modified the
core library&mdash;please send feedback to _devinfo@splunk.com_.
4. File any issues on
[GitHub](https://github.com/splunk/splunk-sdk-python/issues).
Beginning September 2018, the Splunk SDKs for C#, Java, JavaScript, and Python will no longer be supported through Splunk Support.

You can still request assistance using the following options:

* Post questions to [Splunk Answers](http://splunk-base.splunk.com/answers/). Be sure to use tags to identify the SDK or tool you are having an issue with.

* File an issue on [GitHub](https://github.com/splunk/).

* Send feedback to _devinfo@splunk.com_.

### Contact Us

You can reach the Developer Platform team at _devinfo@splunk.com_.
Expand Down
19 changes: 11 additions & 8 deletions splunklib/binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ def get(self, path_segment, owner=None, app=None, sharing=None, **query):

@_authentication
@_log_duration
def post(self, path_segment, owner=None, app=None, sharing=None, headers=None, **query):
def post(self, path_segment, headers=None, **query):
"""Performs a POST operation from the REST path segment with the given
namespace and query.

Expand All @@ -681,7 +681,7 @@ def post(self, path_segment, owner=None, app=None, sharing=None, headers=None, *
the ``autologin`` field of :func:`connect` is set to ``True``.

If *owner*, *app*, and *sharing* are omitted, this method uses the
default :class:`Context` namespace. All other keyword arguments are
default :class:`Context` namespace. All keyword arguments are
included in the URL as query parameters.

Some of Splunk's endpoints, such as ``receivers/simple`` and
Expand All @@ -697,12 +697,6 @@ def post(self, path_segment, owner=None, app=None, sharing=None, headers=None, *
*path_segment*.
:param path_segment: A REST path segment.
:type path_segment: ``string``
:param owner: The owner context of the namespace (optional).
:type owner: ``string``
:param app: The app context of the namespace (optional).
:type app: ``string``
:param sharing: The sharing mode of the namespace (optional).
:type sharing: ``string``
:param headers: List of extra HTTP headers to send (optional).
:type headers: ``list`` of 2-tuples.
:param query: All other keyword arguments, which are used as query
Expand Down Expand Up @@ -733,8 +727,17 @@ def post(self, path_segment, owner=None, app=None, sharing=None, headers=None, *
c.post('saved/searches', name='boris',
search='search * earliest=-1m | head 1')
"""
owner = None
app = None
sharing = None
if headers is None:
headers = []
if 'owner' in query:
owner = query['owner']
if 'app' in query:
app = query['app']
if 'sharing' in query:
sharing = query['sharing']

path = self.authority + self._abspath(path_segment, owner=owner, app=app, sharing=sharing)
logging.debug("POST request to %s (body: %s)", path, repr(query))
Expand Down