Learn How We Can Help You Keep Teleworkers Protected During the COVID-19 Crisis

API & Integration

Reply
Highlighted
Accepted Solution

Multiple Extensible Attributes on Single Python PUT

Techie
Posts: 8
2836     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?

Highlighted

Re: Multiple Extensible Attributes on Single Python PUT

Moderator
Moderator
Posts: 87
2837     0

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

 

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

Highlighted

Re: Multiple Extensible Attributes on Single Python PUT

Community Manager
Community Manager
Posts: 167
2837     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"}}}'

Highlighted

Re: Multiple Extensible Attributes on Single Python PUT

Techie
Posts: 8
2837     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!

Highlighted

Re: Multiple Extensible Attributes on Single Python PUT

Moderator
Moderator
Posts: 87
2837     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