Skip to main content

I'm working on loading data into our SIS from Incident IQ to help track staff and student assigned assets (mostly student, but I figured I might as well grab staff ones while I'm at it), and am trying to figure out how to include the Assets data in my API response from IIQ. I've tried the "/api/v1.0/users" endpoint and also tried creating a view and using the "/api/v1.0/users/view/{view-id}" endpoint. The view includes Assets as a column. I can't seem to get it to return the assigned Assets for the users even though the documentation indicates it should be one of the returned items in the JSON response. 

I’m working with Python since it has a module for working with the API in our SIS.

import requests

url = "https://{iiq_domain}}/api/v1.0/users/view/{view_id}?$p=0&$s=10000"

payload = {}
headers = {
    "Authorization": "Bearer {token_here}",
    "Content-Type": "application/json",
    "Accept": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

 

I have found that documentation to be less than helpful.

In my experience, the assets do not show in the response for a user or a user view, despite what that documentation says.

We are doing something similar to what you’re asking, but had to do it in two parts.

  1. We created an asset view of devices that are assigned to a user (Filter: Asset Owner - Exclude “Not Assigned”) and called that via API to retrieve the users and their asset(s) to update in our SIS.
  2. To handle the deltas, there are a couple of options:
    1. During the first part above, compare all users in your SIS to the output from that API call for the asset view, any user that’s not in the response doesn’t have a device - update your SIS accordingly.   OR
    2. Create a user view of users without an asset (Filter: User Attribute - Exclude “Has assigned device”) and call that view via API to get your output of users without a device to update your SIS accordingly.

@RMoeller 967aff3 emsd63 Thank you for submitting your question to our community! 😄

As ​@jclark is our resident API expert, I hope this is what you are looking for. Thanks J!!


@jclark Sorry, I figured out a workaround late yesterday and hadn’t posted an update yet. What I ended up doing is similar to what you propose. I created an asset view of assigned devices, and then used the filter to pull in that view along with another view that gives me a list of users:

iiq_users_apiURL = f"https://{iiq_domain}/api/v1.0/users/view/{iiq_users_view_id}{iiq_post_params}"
iiq_assets_apiURL = f"https://{iiq_domain}/api/v1.0/assets{iiq_post_params}"

iiq_assets_payload = {
"Filters": r
{
"Facet": "View",
"Id": iiq_assets_view_id
}
]
}

I then group the asset data by owner and put the asset data into a list of dicts, and merge the users and assets data into one pandas dataframe:

iiq_assets_grouped_df = iiq_assets_df.groupby('OwnerId').apply(lambda s: s s'AssetId', 'AssetTag', 'Name']].to_dict(orient='records'),include_groups=False).reset_index(name="Assets")


iiq_df = iiq_users_df.merge(iiq_assets_grouped_df, how="left", left_on="UserId", right_on="OwnerId").fillna("")

Then I compare that with the data in my SIS and update as needed. Thanks!


Reply