Reply
Accepted Solution

Multiple Extensible Attributes on Single Python PUT

mrsold
Techie
Posts: 8
2339     0

I'm attempting to do an API put against Infoblox and add multiple extensible attributes (via Python).  I tried putting the payload in a single [] but that didn't work.  And if I do it in two seperate API calls it appears to overwrite the first attribute.

 

payload1 = '{"extattrs": {"VLAN ID": {"value": "10"}}}'

payload 2 = '{"extattrs": {"Building": {"value": "South"}}}'

 

payload_put_1 = requests.put('https://<infoblox>/wapi/v1.4.2/<_ref>, data=payload1, verify=False, auth=(user,password))

 

payload_put_1 = requests.put('https://<infoblox>/wapi/v1.4.2/<_ref>, data=payload2, verify=False, auth=(user,password))

 

Thoughts?

Re: Multiple Extensible Attributes on Single Python PUT

Moderator BRampling
Moderator
Posts: 69
2340     0

What did you use for the single payload? This should work:

 

payload1 = '{"extattrs": {"VLAN ID": {"value": "10"},"Building": {"value": "South"}}}'

Re: Multiple Extensible Attributes on Single Python PUT

MRichard Community Manager
Community Manager
Posts: 101
2340     0

Yes, use a "extattrs+" call to add an Extensible Attribute value.  Or to remove one, do "extattrs-".

 

For example,

payload1 = '{"extattrs+": {"VLAN ID": {"value": "10"}}}'

and then

payload 2 = '{"extattrs+": {"Building": {"value": "South"}}}'

Re: Multiple Extensible Attributes on Single Python PUT

mrsold
Techie
Posts: 8
2340     0

@BRampling wrote:

What did you use for the single payload? This should work:

 

payload1 = '{"extattrs": {"VLAN ID": {"value": "10"},"Building": {"value": "South"}}}'


This is what I tried first and it didn't work.  Looks like I just had my brackets incorrectly placed.  Thanks for this, it worked!

Re: Multiple Extensible Attributes on Single Python PUT

Moderator BRampling
Moderator
Posts: 69
2340     0

I use this tool to check JSON validation: https://jsonlint.com/, I always mess up my brackets too.

Showing results for 
Search instead for 
Do you mean 

Recommended for You