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

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


1 badge earned


Participate in fun challenges

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


Gift kudos to your peers

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


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!


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
Community Members
Community Events
Community Groups

Using API To Create Alert, Get a "Body Should be a JSON Object 400 error

I'm trying to create an alert in Opsgenie. I created an api integration and I'm using the Geniekey from that integration. 

I'm actually using postman but postman very helpfully outputs a cURL format and that's easier to paste in here: 
curl --location --request POST '' \
--header 'Content-Type: application/json' \
--header 'Authorization: GenieKey <api integration>' \
--header 'Host:' \

--data-raw '{"message": "test message"}'

Result: 500 bad request
"message": "Body should be a JSON object",
"took": 0.0,
"requestId": "<hash>"


Presumably this means that the body of the message isn't JSON but it certainly is. According to the documentation ( the only required field is message so that's all I added.

In my experience the problem will be trivial and obvious but I just can't see it in this case. 

Please help me out and tell me what's wrong here!




1 answer

1 accepted

2 votes
Answer accepted
Nick H Atlassian Team Jan 23, 2023

Hi @Dave Menconi ,

It could be an issue with the headers or data? This curl command seemed to work for my instance:

curl -X POST -H "Content-Type: application/json" -H "Authorization: GenieKey XXXXXXXXXXXX" -d '{"message": "An example alert message", "alias": "Life is too short for no alias", "description":"Every alert needs a description"}'




Thanks so much for trying that, Nick! 
I execute your curl command just as you had it EXCEPT for using my GenieKey.

I got the same error with slightly more information (because I'm using curl instead of postman, I think): 

{"message":"Invalid JSON","took":0.0,"requestId":"XXXXXX"}curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) URL using bad/illegal format or missing URL
curl: (3) unmatched close brace/bracket in URL position 44:
description:Every alert needs a description}'

 It seems to believe that the closing brace is not a brace ("}"). 

The question is, why does it work for you but not for me? 

Just thinking out load here...

We're using the same end point and the same headers and the same body. The ONLY difference is the GenieKey. 

I got this key by creating a custom API integration for this specific alert. I am NOT using the API key manager (that got me a different error) but I'm also not using the "Default API" integration.

Is that the wrong way to do it? 

Nick H Atlassian Team Jan 23, 2023

Hi @Dave Menconi ,

That is the correct way of using the Alert API. The GenieKey needs to be from an API integration, and not from the API key management tab. 

The body's fields typically use double quotes, and the entire body needs to be enclosed by single quotes. Maybe that has something to do with it? 

I get an "Invalid JSON" response if I remove a double quote from the body. The only field that is required to create an alert is the Message, so maybe start with only this field and see if you can generate an alert. Body for that might just be something like:

-d '{"message": "An example alert message"}'


curl -X POST -H "Content-Type: application/json" -H "Authorization: GenieKey XXXXXXXXXX" -d '{"message": "An example alert message"}'
Nick H Atlassian Team Jan 23, 2023

Feel free to share the body, your entire syntax, or a screenshot of the tests. We could review that as well and provide some feedback, suggestions, etc. Just be sure to remove any GenieKeys or sensitive information before sharing.

Basically you HAVE the body; I got it from you, after all. I'm stuck but I've been stuck before (often). This doesn't feel like an API problem, it feels like a configuration or server problem. 
I'm on a chat with OpsGenie support (and they seem to be baffled, too). 

I'll post back here when I figure it out. 

I don't know why the curl command doesn't work. I suspect it's something to do with how I'm pasting it into the command window (I'll probably try it on a linux box and it will probably work). 

The problem I was having with postman (and the Python code I derived from it) was that I was trying to SET the host header. Note to self: don't set the host header. 

If left to itself Postman (and curl and python requests) will set the host header all on it's own. Setting that was the error. The error code was just bogus. 

Thanks for your help. Sorry that this didn't turn out to be a particularly useful community post. You win some you lose some. 


Like Nick H likes this

Suggest an answer

Log in or Sign up to answer
Site Admin

Atlassian Community Events