[PDB Tech] pdb, PUT, python, fail - or maybe stupidity...
Stefan Pratter
stefan at 20c.com
Tue Jan 28 03:47:55 PST 2020
PUT needs you supply values for all required fields not just fields you
want to change, i am guessing that's what is the issue here.
If you check the content of the 400 response you are getting it should
tell you which other fields it wants you to submit in your payload (or
any other reason why it's failing)
PATCH would be the method for partial updates like you are trying to do,
but is currently not enabled/supported on the api.
Stefan
On 28/01/2020 13.05, Elmar K. Bins wrote:
> Hi gents, ladies,
>
> Arnold asked me to post this to the list, maybe I'm just doing something very
> wrong. If anybody has a hint (or experience), that could potentially make me
> happy :-)
>
> Elmar.
>
> ===
>
> I'm trying to update a net object from python, using the requests library with
> the peeringdb RESTful API, essentially doing a PUT operation..
>
> Just in case I'm too stupid to ... here's the whole she-bang
>
> ---------- What I send:
>
> import request
>
> URL = 'https://isc-apiuser:********@peeringdb.com/api/net/12085'
>
> dict_headers = {
> "Accept" : "application/json",
> "Content-Type" : "application/json",
> }
>
> dict_changes = {
> "irr_as_set" : "AS3557",
> }
>
> request.put(url=URL, data=dict_changes, headers=dict_headers)
>
>
> ---------- What I get:
>
> 400 Client Error: Bad Request for url:
> https://isc-apiuser:************@peeringdb.com/api/net/12085
>
> ===
>
> Yes, the user has "update" rights to all net objects (got the 403 when that was
> not the case, so auth works)
> _______________________________________________
> Pdb-tech mailing list
> Pdb-tech at lists.peeringdb.com
> https://lists.peeringdb.com/cgi-bin/mailman/listinfo/pdb-tech
>
More information about the Pdb-tech
mailing list