Skip to content

Commit

Permalink
Merge pull request #26 from billdodd/fix/issue-25
Browse files Browse the repository at this point in the history
Correct incorrect use of x-www-form-urlencoded for POST/PATCH/PUT
  • Loading branch information
mraineri authored Jan 10, 2019
2 parents e4e2f58 + c15ea73 commit 8df54d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 11 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,22 @@ Perform a GET operation
~~~~~~~~~~~~~~~~~~~~~~~~~

A simple GET operation can be performed to obtain the data present in any valid path.
An example of rawget operation on the path "/redfish/v1/systems/1 is shown below:
An example of rawget operation on the path "/redfish/v1/systems/1" is shown below:

.. code-block:: python
response = REDFISH_OBJ.get("/redfish/v1/systems/1", None)
Perform a POST operation
~~~~~~~~~~~~~~~~~~~~~~~~~

A POST operation can be performed to create a resource or perform an action.
An example of a POST operation on the path "/redfish/v1/systems/1/Actions/ComputerSystem.Reset" is shown below:

.. code-block:: python
body = {"ResetType": "GracefulShutdown"}
response = REDFISH_OBJ.post("/redfish/v1/systems/1/Actions/ComputerSystem.Reset", body=body)
Logout the created session
~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
6 changes: 4 additions & 2 deletions src/redfish/rest/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,10 @@ def _rest_request(self, path, method='GET', args=None, body=None, \
if method == 'GET':
reqpath += '?' + urlencode(args)
elif method == 'PUT' or method == 'POST' or method == 'PATCH':
headers['Content-Type'] = 'application/x-www-form-urlencoded'
body = urlencode(args)
LOGGER.warning('For POST, PUT and PATCH methods, the provided "args" parameter "{}" is ignored.'
.format(args))
if not body:
LOGGER.warning('Use the "body" parameter to supply the request payload.')

restreq = RestRequest(reqpath, method=method, body=body)

Expand Down

0 comments on commit 8df54d3

Please sign in to comment.