Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Could not authenticate - Using Java SDK

Hello,

  I'm testing the Opsgenie integration throught Java SDK for a customer that uses Opsgenie for Alert management. I'm using a Trial account as we use Atlassian products extensively but no OpsGenie.

  The Java SDK version I'm using is "2.11.2".

   I've created an API key, and using "https://api.eu.opsgenie.com" as RootUri.

  But I'm always receiving a "Could not authenticate", that is the same response we are receiving when using the Api key provided by the customer. The Api key has enabled all the options: Read, Create and update, Delete, Configuration Access.

  Some weeks ago, when I created the integration there was not problem in authentication, and the code is the same, but currently is not working.

 This is the integration code:

OpsGenieClient opsclient = new OpsGenieClient();
opsclient.setRootUri("https://api.eu.opsgenie.com");

AlertApi client = opsclient.alertV2();
client.getApiClient().setApiKey(getApiKey());

CreateAlertRequest request = new CreateAlertRequest();
request.setMessage(getMessage());
request.setAlias(getAlias());
request.setDescription(getDescription());
request.setUser(getUser());
for (String teamName: getTeam()) {
request.addTeamsItem(new TeamRecipient().name(teamName));
}

SuccessResponse response = null;
try {
response = client.createAlert(request);
} catch (ApiException e) {
LOGGER.error("Unexpected error sending notification", e);
}

  And the response I receive is:

13:59:32.232 [Test worker] ERROR com.nicepeopleatwork.nicemessenger.beans.OpsGenieBeanDelivery - Unexpected error sending notification
com.ifountain.opsgenie.client.swagger.ApiException: {"message":"Could not authenticate","took":0.001,"requestId":"d22b6bde-740f-4765-b5b2-3eb4da8a478a"}
at com.ifountain.opsgenie.client.swagger.ApiClient.invokeAPI(ApiClient.java:681) ~[sdk-swagger-2.11.2.jar:2.11.2]
at com.ifountain.opsgenie.client.swagger.api.AlertApi.createAlert(AlertApi.java:500) ~[sdk-swagger-2.11.2.jar:2.11.2]

  The issue can be related to using a Trial Account (I had no problems some weeks ago)? Or is related to some change in the Api? (I've double checked the examples and the code seems ok).

 

Thanks in advance!

1 answer

0 votes
Nick H Atlassian Team Apr 19, 2021

Hi @Account For Testing Service ,

Based on that error and what you shared, it sounds like the API key provided by the customer could be one from the API Key Management section.

Instead, you will want to use the API key from an API integration. Ideally a global API integration - meaning it is assigned to [No Team].

Can you try this, or have the customer share an API integration's key, and let us know if you run into the same error? Thanks!

Hi @Nick H ,

  Many thanks for the very quick response.

  Finally I managed to create and API Key from the Team Dashboards (Teams -> [Team] -> Integrations -> Add integration). With my trial account I was not able to create the key in the Opsgenie API Integration page.

  But to create the alert I also had to remove this line from my code:

client.setRootUri("https://api.eu.opsgenie.com");

   Some weeks ago, when I first developed the integration, it worked without problems. Based on documentation it can be related to the EU instance of Opsgenie.

Best regards,

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
Community showcase
Published in Opsgenie

New GitLab integration in Incident Investigation view

We launched the first version of the Incident investigation view in April of 2020 for Bitbucket Pipelines. Shortly after that, we added the ability to investigate deployment-related incidents in Opsg...

269 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you