I'm trying to hit 'getMessages' api of Office 365. I tried following url and authorization header in java. But it is giving RESPONSE code 500, which is an internal server error. But when I tried the same from POSTMAN REST CLIENT, it worked perfectly fine. Can anyone suggest what I'm doing wrong?
URL url =new URL("https://outlook.office365.com/api/v1.0/me/messages/");String asB64 ="Basic "+newString(newBase64().encode(user+":"+password.getBytes()));
println "asB64 : "+ asB64;HttpsURLConnection urlConnection =(HttpsURLConnection) url.openConnection();
urlConnection.setRequestProperty ("Authorization", asB64);
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("GET");
urlConnection.setDoInput(true);
urlConnection.setRequestProperty("Content-Type","application/x-www-form-urlencoded,charset=UTF-8");PrintWriter printWriter =newPrintWriter(urlConnection.getOutputStream());
printWriter.flush();InputStream inputStream = urlConnection.getInputStream();String contentType = urlConnection.getContentType();
println "output : "+ urlConnection.getResponseCode()+" message : "+ urlConnection.getResponseMessage()+" error : "+ urlConnection.getErrorStream();