Opsgenie v2 Alert api client's behavior

api̇

#1

Hi,

We are in the process of migrating our clients to start using Opsgenie V2 api since V1 is going to shut down in June.
Now that the actions like creation/deletion etc are processed asynchronously, should the clients make sure the actions are completed by periodically checking the status of the action? like using the Get Request Status?

Or can clients can just post and forget if the response is 202 (accepted) and assume the action would go through fine?


#2

Hi - excuse us for the delay!

It is highly recommended to poll the status with the Get Request Status, if you are unsure about the content of your create/delete requests.

Your request will be processed if we return a 202, but that does not mean successful completion. To give you a quick example, imagine you are sending an Add Note request and the alert you are targeting does not exist. It might be, that the alias/id you stored was false or had a mistake. In that case, the API will accept it and the request is processed, but an error will be logged stating, that the alert does not exist.

In short - the Get Request Status can verify, if you’ve sent the correct data and your action has been executed. 202 guarantees that we will execute, but does not guarantee your expected result from the request.


#3

I’ve noticed that you need to leave a little time before requesting the status. If I don’t put in a 1 sec sleep between the request and the get status that I will often get a no such request error. Its a little slow on the uptake.


#4

Definitely need a bit of delay there. As far as I know, our average process time is around 30ms, but given that the network can have delays as well, it’s certainly recommended. The “get request status” also take a couple milliseconds.

We actually recommend an even greater sleep period, perhaps 250ms to dodge the problems coming from network costs, edge cases and of course very high traffic spikes.