Skip to main content
Solved

Get all action attachments from event and other nested elements


Forum|alt.badge.img+7

 
I’m rather new to the use of assystREST API, and I do apologize if this is blindingly obvious.


 I’ve tried using the Assyst wiki assystREST_More_Examples article as a guide, but I’ve come up short. 
Is it possible to get all attachments from an event using a single rest query?


When using the query below the “Event attachments” are returned, however none of the “Action Attachments” are part of this response. 

GET http://:/assystREST/v2/events/[eventId]/attachments

  
I have attempted using the actions endpoint, however that does not return any of the “Event Attachments”, and this returns all the actions, not just the attachments. 

GET http://:/assystREST/v2/actions?eventId=[eventId]&fields=attachments

  I’ve so far thus been unable to get a single request response, and i’m unsure as how to structure more advanced queries. 

In the same line of inquiry, I’ve been trying to lookup get all open events that are within a certain siteArea. 

This is trivial using the assyst GUI, however using REST I’ve been unable to structure a query for this, or the flip side, return what the siteArea is for a given event.

 

The use case for the latter is to help improve an external dashboard used for incident handling and aims to add a broader location insight into these events. Such insight is desired by our 24/7 staff to better evaluate if there is a broader geographic component, uniting incidents triggered during the night.


Are such nested queries even possible, and if they are there some examples to be shared, or guidance on how to go about creating them? 

 

Thank you very much for your time

Best regards

Richard

Best answer by Rajana

Apologies for my misunderstanding. 
Use the following query to retrieve data for all the attachments (direct attachments to the event & attachments through actions) 

  assystREST/v2/events/42?fields=attachments,actions.attachments

You can adjust the details should returns as follows

assystREST/v2/events/42?fields=attachments[name],actions.attachments[name]

View original

4 replies

Forum|alt.badge.img+3
  • Do Gooder (Employee)
  • 20 replies
  • January 14, 2025

Can you try the following GET request which will return all the attachments in the event 
134 is the event id

assystREST/v2/events/134?fields=[attachments]


Forum|alt.badge.img+7
Rajana wrote:

Can you try the following GET request which will return all the attachments in the event 
134 is the event id

assystREST/v2/events/134?fields=[attachments]

Hello, Ranjana

Thank you very much for your reply. 

 

I attempted using the provided advice of using square brackets 

A bit of context:
The queried event in the following images has a single .txt as event attachment, and a differently named single .txt file an explicit action attachment. Alongside there are some inline images in the actions, that count as action attachments.

 

I attempted this query:

assystREST/v2/events/5958253?fields=[attachments]

This query also only return “Event Attachments”, and no attachments added as part of actions performed on the event.

 

This is very similar to the results from the events/eventId/attachment.   

assystREST/v2/events/5958253/attachments
Comparrison of using events/{eventId}/attachments vs events/{eventId}?fields=[attachments]

 

Improvements to the action attachment query:

The following example does not solve the problem at hand, however i would like to share my findings in case it can be of use for someone else. 

Using the brackets to enclose “attachments” in the query helped to reduce some of the “noise” when querying the action endpoint: 

assystREST/v2/actions?eventId=5958253&fields=[attachments]

 

 

 Compared to the verbosity without the square brackets: 

 

While this was very interesting to learn, I still need some help with my original issues in regard to all attachments in an event and event siteArea

 

Best regards

Richard


Forum|alt.badge.img+3
  • Do Gooder (Employee)
  • 20 replies
  • Answer
  • January 19, 2025

Apologies for my misunderstanding. 
Use the following query to retrieve data for all the attachments (direct attachments to the event & attachments through actions) 

  assystREST/v2/events/42?fields=attachments,actions.attachments

You can adjust the details should returns as follows

assystREST/v2/events/42?fields=attachments[name],actions.attachments[name]


Forum|alt.badge.img+7

Thank you very much!

This latest set of examples was exactly what I was looking for, and it has helped me grasp some areas I was stuck on, or had previously had misunderstood. 😊

 

In case anyone else stumbles upon this thread with similar questions, I'll try to answer the reimaing questions I raised, and what made it click for me.

To find the list of possible query parameters, consult the RAML:

assystREST/v2/events/raml

assystREST/v2/events/raml/latest

Find the queryParameters listed in the second latest half:

/events:
  type: collection
  get:
    queryParameters:
      $orderby:
        type: string
      $skip:
        type: integer

Using the list of event queryParameters in the RAML, constructing a valid query is a breeze:

All open Incidents in specific building: 

assystREST/v2/events?eventType=incident&eventStatus=open&buildingId=234


Number of open incidents from a specific site:

assystREST/v2/events/searchResultCount?eventType=incident&eventStatus=open&siteId=269


The “nested queries” I was having issues with is Field Expansion, and the nested details I was looking for can be retrieved with a simple query:

assystREST/v2/events/12434181?fields=[*,room[].building[remarks].site[].siteArea[].territory[remarks]]

 

Once again, ​@Rajana, thank you very much for setting me on the right track😊

 

Kind regards,

-Richard


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings