Has anyone integrated Ops genie with share point for on call rota visibility for non ops genie user
Asked by Anish Singh:

I am looking to make the IT rota public, hence looking to integrate the rota with share point which can be made public inside the org. Has someone done this, and can you please share how you did it ?


Answers:
author: Andrew Laden
body: I have done this, but it took a good deal of perl scripting.

I would basically use API calls to OpsGenie to get the oncall users. Examples of API endpoints that i used..

Get on call user : schedules/$rotation/on-calls?scheduleIdentifierType=name

get next on call user: schedules/$rotation/next-on-calls?scheduleIdentifierType=name

get all users in rotation: schedules/$rotation?identifierType=name

I would generate the ordered on call list

* To determine sharepoint order.
* On call is first
* Rotate the rotation till the next on call is first.
* Add to order as long as it isnt in there already.

Then I would use Sharepoint's API to update that list to a list in sharepoint. Using things like the "lists/GetByTitle" endpoint, and building the structure that sharepoint wants.

I'll be honest here, it took a lot of debugging and really delving into the details of how both the Opsgenie REST API and the Sharepoint REST API worked. I wrote a few perl libraries to handle a lot of the details to get some re-usability out of it.

But it is possible to look up the on call users and rotation, and post that to a sharepoint list for users to see.

Another option you may want to look at is to leverage the ical support in OpsGenie

<https://support.atlassian.com/opsgenie/docs/view-your-on-call-schedule/>

that might be good enough for what you want to do.

comments: author: Anish Singh
body: Thanks Andrew, your answer is driving away from this solution, might be hard to maintain this in the long run with no devs on our side. Might use the teams and ical solution and see which gives me best results.


author: Boris Zozoulia
body: ical support in OG is the best option for SharePoint, however, in my organisation, we have limited access to SharePoint features, and could not leverage on the ical data extracted from OG :(

Sharepoint offers a great Power Automate feature, where you can create a custom flow, which can be made to get executed daily at a certain time.

No Perl scripting as such is required, as power automate provides a visual designer to create such an automation task.

**Prerequisites:**

A general knowledge of how to create SharePoint lists, and render them as calendar

A SharePoint list is created on your site

OG API key is known

Knowledge of restful APIs and JSON parsing is a must.

**Flow**

1. the flow will get the timeline of OG for a given schedule (restful OG API call) Timeline since a certain date. Please note the entries in the JSON response will be sorted by date. Please also note - we will be getting the timeline since a certain date (in my example it is the last month and for the next 2 months (interval is 12 weeks) ) to ensure we have enough historical data to be rendered on the Sharepoint website. This is driven by the \`utcOneMonthAgo\` variable set to \`  
subtractFromTime(utcNow(),1,'Month')\` in the screenshot

2. then the flow will clear up the existing list in Sharepoint, to make sure we don't get duplicate entries

3. then the flow will parse the JSON response obtained in the first step, using the JSON schema (generated from sample JSON response)

4. then the flow will loop through the parsed JSON and add the required attributes to the list, cleared up in step 2.

![powerautomate-rota.png](https://community.atlassian.com/t5/image/serverpage/image-id/274548i05263292DD0E9BA2/image-size/large?v=v2&px=999 "powerautomate-rota.png")

**Additional settings in SharePoint list**

The result of the flow will look like :

![default-list-view.png](https://community.atlassian.com/t5/image/serverpage/image-id/274549i9FA7F33B16691B03/image-size/large?v=v2&px=999 "default-list-view.png")

the list used in flow can be rendered as a calendar natively via SharePoint. Select list properties and create a new view, with the "Show as" option set to the calendar. Specify the fields for start and end dates  
![calendar-view.png](https://community.atlassian.com/t5/image/serverpage/image-id/274551i96DE0D836FD82C4F/image-size/large?v=v2&px=999 "calendar-view.png")

Now the new View can be used either as a default one in the list or, this view can be embedded into any Shapoint page contact where it is required.

![calendar-result.png](https://community.atlassian.com/t5/image/serverpage/image-id/274552iA3BDA03A41EC96FB/image-size/large?v=v2&px=999 "calendar-result.png")

Power Automate offers some great scriptless features to grab external data and place it into SharePoint as content.

Good luck

comments: author: Kade Kerschen
body: Great write up, I'm trying to use Power Automate for this same process. I'm getting hung up on the "Apply to Each 2" portion. Any clues?

![error.png](https://community.atlassian.com/t5/image/serverpage/image-id/280509i77321910B2FE2A26/image-size/large?v=v2&px=999 "error.png")


author: Boris Zozoulia
body: [@Kade Kerschen](/t5/user/viewprofilepage/user-id/5315785) I assume "Apply to Each 2" is referring to the same as I have in my screenshot.  

If that's the case that assertion depended on a previous one (Parse JSON) which contains "schema"

To get the schema - make a sample ops genie call (via curl rest API) obtain the JSON response paste it into Parse Json assertion - and it will generate a schema out of that response.

There are a lot of unneeded details in that schema since the OG response contains a lot of irrelevant details for the purposes of what I need. Either clear all the non-needed attributes in the generated schema, or select the correct one from the list (they will be all named the same, like in the title example where I am referring to \`name\` twice, but those are different attributes one is for persona name, another one is for rotation name).

The thing is Power Automate UI will provide you a drop-down list with the colour-coded (by assertion) attribute suggestions, and if the extracted attribute names are the same - they will be displayed as duplicates, yet they would reference the actual parse4d json attributes.

I had to do a number of trial-and-error parsing attempts to get things running right

You can always log debug your flow and it will tell you better error output than the one you have mentioned