API Access to Incidents using Requested By to Filter

Looking to use the API to get a user's most recent incidents. Using the web interface, I can see that you can filter by user using requested_by. When doing this it uses a numeric ID, that thus far I've been unable to figure out how to get. It isn't the user id or the group id for the user. Any idea on how I can get this ID or another way to filter?

Thanks

Parents
  • Well I used a hack to get what I needed but it isn't pretty. If you load a user's profile in the web interface, there is a link like "See all X incidents" and that link include the requested_by id. The URL for this is basically: 

    /user_cards/{0}?klass=users&related=true where {0} is the user id of the user. 

    Extract out the link and pull out the requested_by_id and then post it over to the incidents API with the count that I want and I have the incident history for that user.

    API_URL = _configuration["SWSDApiUrl"] + "incidents.json?requested_by=" + requested_by_id + "&sort_by=number&sort_order=DESC&per_page=" + count;

    Edge cases:

    - If the user only has a singe incident, there will only be a link to the one incident. To solve this you can just use the that link and hit the incident API adding on the .json to the end of the link.

    - If the user doesn't have any tickets, there will be no links. 

    Hopefully there is a better way to do this, but for now I'm getting what I need. 

Reply
  • Well I used a hack to get what I needed but it isn't pretty. If you load a user's profile in the web interface, there is a link like "See all X incidents" and that link include the requested_by id. The URL for this is basically: 

    /user_cards/{0}?klass=users&related=true where {0} is the user id of the user. 

    Extract out the link and pull out the requested_by_id and then post it over to the incidents API with the count that I want and I have the incident history for that user.

    API_URL = _configuration["SWSDApiUrl"] + "incidents.json?requested_by=" + requested_by_id + "&sort_by=number&sort_order=DESC&per_page=" + count;

    Edge cases:

    - If the user only has a singe incident, there will only be a link to the one incident. To solve this you can just use the that link and hit the incident API adding on the .json to the end of the link.

    - If the user doesn't have any tickets, there will be no links. 

    Hopefully there is a better way to do this, but for now I'm getting what I need. 

Children
No Data