Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
How to use "assign_state" to extract the value from an extensible attributes
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2018 12:59 AM
6726     0
I sent the following request
[ { "method": "GET", "object": "record:srv", "data":{"name":"_sip._tcp.vega.com", "view":"default"}, "args":{"_return_fields+":"extattrs"}, "assign_state": {"ref": "_ref", "ea":"extattrs"}, "discard":true}, {"method": "STATE:DISPLAY"} ]
and got such response:
[ { "ref": "record:srv/ZG5zLmJpbmRfc3J2JC5fZGVmYXVsdC5jb20udmVnYS9wcml2aWxlZ2UzLTEvMC8wLzUwMDAvdmVnYS5jb20:_sip._tcp.vega.com/default", "ea": { "Site": { "value": "ABC" } } } ]
My question is how to put the value of the EA "Site" into an variable, so that I can use it in the following request items., such as this:
[ { "method": "GET", "object": "record:srv", "data":{"name":"_sip._tcp.vega.com", "view":"default"}, "args":{"_return_fields+":"extattrs"}, "assign_state": {"ref": "_ref", "ea":"extattrs"}, "discard":true}, {"method": "STATE:DISPLAY"}, { "method": "PUT", "object": "##STATE:ref:##", "enable_substitution": true, "data":{"extattrs":{ "Site": {"value":"##STATE:ea.Site.value:##"} }}}
what I got now is such an error:
{ "Error": "AdmConProtoError: Variable ea.Site.value not found in the current request state {u'ref': 'record:srv/ZG5zLmJpbmRfc3J2JC5fZGVmYXVsdC5jb20udmVnYS9wcml2aWxlZ2UzLTEvMC8wLzUwMDAvdmVnYS5jb20:_sip._tcp.vega.com/default', u'ea': {'Site': {'value': 'ABC'}}}", "code": "Client.Ibap.Proto", "text": "Variable ea.Site.value not found in the current request state {u'ref': 'record:srv/ZG5zLmJpbmRfc3J2JC5fZGVmYXVsdC5jb20udmVnYS9wcml2aWxlZ2UzLTEvMC8wLzUwMDAvdmVnYS5jb20:_sip._tcp.vega.com/default', u'ea': {'Site': {'value': 'ABC'}}}" }
Solved! Go to Solution.
Re: How to use "assign_state" to extract the value from an extensible attributes
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2018 11:07 PM
6726     0
Hi,
Here is an example from the WAPI document. Let me know if this works for you.
Use a POST request to copy extensible attribute “Building” from an existing network to a new one using “assign_state” to save the value in the state object: https://1.2.3.4/wapi/v2.9/request With a body: [{ "method": "GET", "object": "network", "data": { "network": "10.1.0.0/16" }, "args": { "_return_fields+": "extattrs" }, "assign_state": { "ea_value": "*Building" }, "discard": true }, { "method": "POST", "object": "network", "data": { "network": "20.1.0.0/16", "extattrs": { "Building": { "value": "##STATE:ea_value:##" } } }, "enable_substitution": true }]
Regards,
Krishna
Re: How to use "assign_state" to extract the value from an extensible attributes
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2018 06:13 PM
6726     0
Thanks a lot, it works well!