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

I can't send details param in rest api

Bruno Willian Conke das Neves February 29, 2024

This is my request: 

 

curl --location 'myUrl' \
--header 'X-OpsGenie-Key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
--header 'Content-Type: application/json' \
--header 'Cookie: __cf_bm=ckl61dMKQWxlJnqbN241pQyu9qXIkROu.21cQCTCVa0-1709231789-1.0-AYSDGyb3aGOTAsSRTDa9XleOUXhK7YYys+QjJxzM+w1EK7QtgNAgwoBJx0aH7wEvDjHW/434zuKihOuD3HVAeCk=' \
--data '{
"description":"test description",
"details":{"key1":"value1","key2":"value2"},
"source":"contrel",
"message":"test",
"priority":"P3",
"isExtraPropertiesWithKey": "true"
}'

 

I'm using the documentation as a reference:
https://docs.opsgenie.com/docs/alert-api#create-alert

 

This is result: 

 

error.png

 

what is wrong?

1 answer

1 accepted

0 votes
Answer accepted
Nick Haller
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 29, 2024

Hi @Bruno Willian Conke das Neves ,

The JSON body (which looks correct) you shared compared to the screenshot looks to be a for different alert?

I would check the Logs tab to see if the request was received by Opsgenie. If the request was received - but an alert was not created - then this Community post should help troubleshoot why that did not occur: 

Integration not creating Opsgenie alert

 

If that JSON body is for the alert you shared, I would review the alert's Activity log tab to see if some sort of alert policy is applying to the alert and modifying the fields such as the details (aka extra properties).

 

Again, the body you shared looks correct.

Bruno Willian Conke das Neves February 29, 2024

Hi,


The json is the same structure as the alert, I just change some values.

I saw the logs and it looks like everything was created correctly.

erro2.png

 

 

Nick Haller
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 29, 2024

Is there any chance of sharing the actual JSON and not just the structure?

If not - I would suggest reaching out to Opsgenie support so they can take a deeper look into your instance and review why the details are not being added through the alert API.

Bruno Willian Conke das Neves February 29, 2024

Here is the real json used

 

{
"description":"Só sei que nada sei, por isso errei.",
"details":{"key1":"value1","key2":"value2"},
"source":"contrel",
"message":"Teste Titulo do erro",
"priority":"P3",
"isExtraPropertiesWithKey": "true"
}

 and here is the complete Curl

curl --location 'myurl' \
--header 'X-OpsGenie-Key: mykey' \
--header 'Content-Type: application/json' \
--data '{
"description":"Só sei que nada sei, por isso errei.",
"details":{"key1":"value1","key2":"value2"},
"source":"contrel",
"message":"Teste Titulo do erro",
"priority":"P3",
"isExtraPropertiesWithKey": "true"
}'

 

 

Nick Haller
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 29, 2024

Hi Bruno,

Thank you for sharing that.

Testing in Postman with the same body shared above, I created an alert as expected with the details (extra properties) added as expected:

alertapi1.jpgalertapi2.jpg

 

One thing I would suggest also reviewing is the create alert action being used for this alert in the API integration. Maybe the action is wiping the extra properties at creation, and should at the very least have this configured to dynamically parse those fields / values:

alertapi3.jpg

 

Otherwise Opsgenie support should be able to assist further.

Bruno Willian Conke das Neves February 29, 2024

Hi Nick,

 

That was it, thank you very much.

Like Nick Haller likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events