Results of single extension attribute via API

thoule
Valued Contributor II

Got this, but it returns all EAs (curl -u user:pass https://server-int.company.org:8443/JSSResource/computers/id/2134 | xpath '/computer/extension_attributes/extension_attribute')

I'd like only a single attribute specified by ID 45. Anyone have a good way to do that?

2 REPLIES 2

mm2270
Legendary Contributor III

If the EA value is on a single line and not something that would have multiple lines, something like this

curl -H "Accept: application/xml" -sfku user:pass https://server-int.company.org:8443/JSSResource/computers/id/2134/subset/extensionattributes | xmllint --format - | grep -A4 "<id>45</id>" | awk -F'>|<' '/value/{print $3}'

There might be a better way of doing this though, but the above is probably the approach I'd take.

thoule
Valued Contributor II

Thanks, @mm2270 xmllint is a good tool I should use more.