[GH-ISSUE #83] PUT do not… put the data in the body #44

Closed
opened 2026-02-27 15:46:09 +03:00 by kerem · 2 comments
Owner

Originally created by @RaitoBezarius on GitHub (Dec 29, 2021).
Original GitHub issue: https://github.com/proxmoxer/proxmoxer/issues/83

I am trying to PUT some configuration using Proxmox API using:

instance.config.put({'cores': 6})

I'm getting this:

  File "/nix/store/s4lhij5bix5zcjgcl1x227mc64n7jwav-python3-3.9.9-env/lib/python3.9/site-packages/proxmoxer/core.py", line 129, in put
    return self(args)._request("PUT", data=data)
  File "/nix/store/s4lhij5bix5zcjgcl1x227mc64n7jwav-python3-3.9.9-env/lib/python3.9/site-packages/proxmoxer/core.py", line 105, in _request
    raise ResourceException(
proxmoxer.core.ResourceException: 501 Not Implemented: Method 'PUT /nodes/askeladd/qemu/401/config/{'cores': 6, 'digest': 'fe5571b2e1aa65b2d6078c1ae9b8302d7e7b98db'}' not implemented

I assume this is due to https://stackoverflow.com/questions/11832639/how-to-specify-python-requests-http-put-body which tries to put the data as a query string, it might be fixed by using json= instead of data= for PUT requests.

Originally created by @RaitoBezarius on GitHub (Dec 29, 2021). Original GitHub issue: https://github.com/proxmoxer/proxmoxer/issues/83 I am trying to `PUT` some configuration using Proxmox API using: ```python instance.config.put({'cores': 6}) ``` I'm getting this: ``` File "/nix/store/s4lhij5bix5zcjgcl1x227mc64n7jwav-python3-3.9.9-env/lib/python3.9/site-packages/proxmoxer/core.py", line 129, in put return self(args)._request("PUT", data=data) File "/nix/store/s4lhij5bix5zcjgcl1x227mc64n7jwav-python3-3.9.9-env/lib/python3.9/site-packages/proxmoxer/core.py", line 105, in _request raise ResourceException( proxmoxer.core.ResourceException: 501 Not Implemented: Method 'PUT /nodes/askeladd/qemu/401/config/{'cores': 6, 'digest': 'fe5571b2e1aa65b2d6078c1ae9b8302d7e7b98db'}' not implemented ``` I assume this is due to https://stackoverflow.com/questions/11832639/how-to-specify-python-requests-http-put-body which tries to put the `data` as a query string, it might be fixed by using `json=` instead of `data=` for PUT requests.
Author
Owner

@RaitoBezarius commented on GitHub (Dec 29, 2021):

I'm always confused by how to use .post/.put :P, but right, instance.config.put(**{'cores': 6}) is the way to go. Sorry for the issue.

<!-- gh-comment-id:1002363726 --> @RaitoBezarius commented on GitHub (Dec 29, 2021): I'm always confused by how to use `.post/.put` :P, but right, `instance.config.put(**{'cores': 6})` is the way to go. Sorry for the issue.
Author
Owner

@jhollowe commented on GitHub (Dec 29, 2021):

yes, the data needs to be parameters to the function rather than a single dict.

<!-- gh-comment-id:1002734632 --> @jhollowe commented on GitHub (Dec 29, 2021): yes, the data needs to be parameters to the function rather than a single dict.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/proxmoxer#44
No description provided.