REST API Network Adapters primary and secondary Mac address

cat123
New Contributor

Hello, I am using the Casper REST API to populate our Asset Management database in ServiceNow.

I am using the resource URL ../computers/subset/basic

This URL provides most of the information I need for my queries.

However, I need BOTH the Primary Mac Address AND the Secondary Mac Address. That URL provides only one field <mac_address>.

Also, I tried building a computer report and pulling from ../computerreports

However, the report builder only provides a single mac address.

What resource URL can I use to query both network adapters for a single computer?

I’m unable to locate a table that stores network adapters specifically.

Let me know if anyone has any advice!

Thank you!

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

@cat123 For a single computer, you'll want to use the following path, where "$computername" is the name of the computer, or a variable that represents the name.

https://your.jssserver.com:8443/JSSResource/computers/name/$computername/subset/general

The above will provide the primary and secondary MAC addresses and a bunch of other data, but won't include all information on the record. Unfortunately, this only works on a single system query. You can't pull up your entire computer inventory in one shot with this and include the 2 MAC addresses.

FYI, this also works with other identifiers, like JSS ID, Serial Number or UUID, etc. Just change "name" above to "id", "serialnumber" or "uuid" for example.

View solution in original post

4 REPLIES 4

mm2270
Legendary Contributor III

@cat123 For a single computer, you'll want to use the following path, where "$computername" is the name of the computer, or a variable that represents the name.

https://your.jssserver.com:8443/JSSResource/computers/name/$computername/subset/general

The above will provide the primary and secondary MAC addresses and a bunch of other data, but won't include all information on the record. Unfortunately, this only works on a single system query. You can't pull up your entire computer inventory in one shot with this and include the 2 MAC addresses.

FYI, this also works with other identifiers, like JSS ID, Serial Number or UUID, etc. Just change "name" above to "id", "serialnumber" or "uuid" for example.

steds
New Contributor

Has anyone come up with a way to pull the primary and secondary MAC addresses for ALL computers using REST API?

dubel
New Contributor III

Now I need to do this, has anyone found a solution?

"Has anyone come up with a way to pull the primary and secondary MAC addresses for ALL computers using REST API?"

mm2270
Legendary Contributor III

While this seems a little like duplication of effort (and it is), one thing I can think of would be to create an Extension Attribute that captures the secondary MAC addresses and populates these into a field in the db for each machine. Then create a saved advanved search that includes that EA value in the columns. When you pull the report via the API, it will include that additional information in it. The trick is to not add any criteria in the saved report. Just leave criteria blank and assign the columns of data you want. By leaving criteria empty, it will by default pull all Macs in your inventory. You could off course add criteria to grab only a subset of systems that match a search as well.

The API pull may take a little while on each run because it generates the report on access, so it's about the same as clicking View for a saved report.
The above is the only way I can think of to do this in a single API pull without needing to pull each device one by one in a loop, which would be a lot of API calls and take some time, depending on how many Macs we're talking about.