Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,458,389
Community Members
 
Community Events
176
Community Groups

StatusPage API: create incident specifying new status

In the documentation, it is shown how to define an array. But if I am not mistaken, in order to define the new status of a new incident I would need to use a map and I don't figure out how to do this.

From the documentation, how to define an array (components):

// JSON
{
  "incident": {
    "name": "test incident",
    "components": ["8kbf7d35c070", "vtnh60py4yd7"]
  }
}

// Form Encoded (using curl as an example):
curl -X POST https://api.statuspage.io/v1/example \
  -d "incident[name]=test incident" \
  -d "incident[components][]=8kbf7d35c070" \
  -d "incident[components][]=vtnh60py4yd7"

 

To create an incident and set the new status, I should define these (among others; name, etc):

  • components: Map of status changes to apply to affected components
    • component_id: Map of status changes to apply to affected components  ("operational" "under_maintenance" "degraded_performance" "partial_outage" "major_outage" "")
  • component_ids: Array of strings. List of component_ids affected by this incident

 

Belo, my unsuccessful tries below:

-d "incident[component_ids][]=yxrqcr0kc3hx"  \
-d "incident[components][component_id][]={'yxrqcr0kc3hx' : 'major_outage'}"
-d "incident[component_ids][]=yxrqcr0kc3hx" \
-d "incident[components][component_id][yxrqcr0kc3hx]=major_outage"
-d "incident[component_ids][]=yxrqcr0kc3hx" \
-d "incident[components][component_id]['yxrqcr0kc3hx']=major_outage"

 

Please, any help will be welcome.

Thanks

3 answers

1 accepted

0 votes
Answer accepted

I have just figured it out:

-d "incident[component_ids][]=yxrqcr0kc3hx" \
-d "incident[components][yxrqcr0kc3hx]=major_outage"

Now, it makes totally sense.

OK, I get it. You specify the ID of the component, then you specify what value you want that that component to be, based on its ID.

The REST API documentation on the vendor's website isn't exactly helpful or illustrative; it just provides a lump of JSON without much explanation. Providing a cURL example that's just a tiny snippet of what's shown in the JSON example doesn't help either.

Like Margaret Boisvert likes this

From what I can understand on the StatusRest API documentation page, in the Create an Incident section, it looks like when you create an Incident, you can create a Component on the Incident Page and give that Component an ID in the form of some name as a string.

You don't seem to be able to set the value of that Component when the page is being created, rather you have to update the value of the new Component after the page has been created by doing a Component PATCH request and referring to it by its ID and the Page ID using the endpoint:

/pages/{page_id}/components/{component_id}

So, I'd say you create the Incident page with the Component on it, parse the ID of that page and the ID of the Component from the response, then submit a new request to update the Component's value on that page by submitting a new request.

No, the components already exist. And users want to create an incident because something is wrong in those existing components. As part of this reporting process or incident creation, users need to define the new status on the affected components. Otherwise, they stay with their default value: Operational. Hence, the effect is as no incident was created.

The explanations I posted of "components" and "component_ids" are not my words, it also comes from the StatusPage API documentation - create incident 

In my opinion, your proposal is a workaround but not the proper way to do it. With your proposal, all our customers would receive two notifications: one with the creation of the incident and another adjusting the status of the component in the new incident. There must be a way to add the map data in the curl command.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events