calling xmatters from java rest client

Not Yet Reviewed

I am calling xmatters from rest client and getting below

getResponseCode...302
getResponseMessage...Found

what does it mean?

It will be very helpful if someone can post sample java code to post data to xmatters.

 

Thanks :) 

 

0

Comments

5 comments
Date Votes

Please sign in to leave a comment.

  • Hi Udayan,

    Can you please be a bit more specific?

    Perhaps let us know what calls your trying to make, how your trying to authenticate?

    Can you post a snippet?

    Thanks,

    Jordan.

    0
  • Hi Jordan,

    I am trying to post request like below.

    restUrl = new URL("https://xxx.hosted.xmatters.com/reapi/2015-04-01/forms/1193c423-6165-6cbc-5e14-55ceb83f08fd/triggers");

    byte[] message ="username:password".getBytes(StandardCharsets.UTF_8);
    String encoding = "Basic " + Base64.getEncoder().encodeToString(message);

    HttpURLConnection httpConnection = (HttpURLConnection)restUrl.openConnection();
    httpConnection.setRequestProperty("Content-Type", "application/json");
    httpConnection.setRequestMethod("POST");
    httpConnection.setRequestProperty("Accept", "application/json");

    httpConnection.setRequestProperty("Authorization", encoding);


    Its not being authenticated. If I use http instead of https, its giving response code 302

    0
  • Hi Udayan  - I ran your original question by our awesome client assistance team. They think they might know the issue, but don't want to guess. Please file a support ticket and client assistance will take good care of you.

    0
  • Hi Udayan,

    Iain here from the xMatters Product Management team.

    An HTTP 302 response code indicates that a redirect exists on the URL you are trying to hit. Our API is secured by HTTPS/SSL so that could explain why you are getting a 302 when you POST to the endpoint using HTTP.

    I think the real issue to solve here is why the basic authentication is failing when you hit the HTTPS endpoint.

    What's the response you get when you hit the URL using HTTPS?

    0
  • Hi Iain,

    Thank for the reply, there were authentication issue actually, Now its resolved.

    Thanks,

    Udayan.

     

    0

Didn't find what you were looking for?

New post