Skip to main content
Question

Results of single extension attribute via API

  • July 23, 2015
  • 2 replies
  • 28 views

Forum|alt.badge.img+15

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

mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • July 23, 2015

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.


Forum|alt.badge.img+15
  • Author
  • Contributor
  • July 23, 2015

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