UiPath Orchestrator API - /odata/QueueItems({Id}) - GET - Receiving HTML Response - Status Code 200 - When I call from JAVA using Spring RestTemplate

I am trying to invoke the following UiPath Orchestrator REST API from my java code. GET /odata/QueueItems({Id}) I am getting the valid JSON response via postman. But when I tried to invoke the same via my java code using spring resttemplate, I am getting some HTML response which I don’t understand but status code is 200.

public String getQueueItemProgress() throws JsonProcessingException, IOException
{

String authToken = "XXXXX";

RestTemplate restTemplate = new RestTemplate();

HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));

httpHeaders.set("Authorization", "Bearer " + authToken);
httpHeaders.set("X-UIPATH-TenantName", "SampleTenantName");
httpHeaders.add("user-agent",
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36");


HttpEntity<String> entity = new HttpEntity<String>("parameters", httpHeaders);

String uri = "https://platform.uipath.com/SampleTenant/SampleTenantName/odata/QueueItems("+this.queueItemId+")";

**ResponseEntity<String> rspEntity= restTemplate.exchange(uri, HttpMethod.GET, entity, String.class);**
String queueItemRsp = rspEntity.getBody();
HttpStatus httpStatus= rspEntity.getStatusCode();

System.out.println("queueItemRsp : "+queueItemRsp);
System.out.println("httpStatus : "+httpStatus.value());

JsonNode jsonNode = mapper.readTree(queueItemRsp);
return jsonNode.get("Progress").textValue();

}

Expected Response

{
@odata.context”: “UiPath”,
“QueueDefinitionId”: 240278,
“OutputData”: “{"DynamicProperties":{"SessionId":"zyjnukdt"}}”,
“AnalyticsData”: null,
“Status”: “Successful”,
“ReviewStatus”: “None”,
“ReviewerUserId”: null,
“Key”: “562a204f-d069-481f-8f3c-e8ff159ee53f”,
“Reference”: null,
“ProcessingExceptionType”: null,
“DueDate”: null,
“Priority”: “Normal”,
“DeferDate”: null,
“StartProcessing”: “2019-08-28T10:57:24.603Z”,
“EndProcessing”: “2019-08-28T10:57:52.873Z”,
“SecondsInPreviousAttempts”: 28,
“AncestorId”: null,
“RetryNumber”: 0,
“SpecificData”: “{"DynamicProperties":{"UserName":"7","SessionId":"zyjnukdt"}}”,
“CreationTime”: “2019-08-28T10:57:11.187Z”,
“Progress”: null,
“RowVersion”: “AAAAAAOjT6s=”,
“Id”: 21563510,
“ProcessingException”: null,
“SpecificContent”: {
“UserName”: “7”,
“SessionId”: “zyjnukdt”
},
“Output”: {
“SessionId”: “zyjnukdt”
},
“Analytics”: null
}

Actual Response

<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="description" content="" />
    <meta name="author" content="" />
    <meta name="referrer" content="no-referrer" />

    <base href="/SampleTenant/SampleTenantName/" />

    <title>UiPath Orchestrator </title>
    <link rel="shortcut icon" href="favicon.ico" />
    <link rel="manifest" href="manifest.json">


    <script type="text/javascript" src="dist/assets/js/preload.js"></script>
    <link rel="stylesheet" type="text/css" href="dist/assets/preloader.css" />
    <link rel="stylesheet" type="text/css" href="dist/default.theme.css" />

    <link rel="stylesheet" type="text/css" href="dist/css/noto/noto-font-jp-zh-woff.css" />
    <link rel="stylesheet" type="text/css" href="dist/css/noto/noto-font-jp-zh.css" />
    <link rel="stylesheet" type="text/css" href="dist/css/material-icons/material-icons-fontface.css" />
    <link rel="stylesheet" type="text/css" href="dist/styles.css" />

        <script type="text/javascript" src="dist/js/mixpanel-init.js"></script>
</head>
<body class="light">
    <ui-app>
        <div class="loader-container">
            <div class="loader-logo">
                <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 612 612">
                    <path fill="#FFF" d="M128.922 155.394h54.237v175.817c0 66.391 25.255 88.371 62.192 88.371 37.411 0 63.125-21.98 63.125-88.371V155.394h52.378v171.604c0 100.538-44.892 139.813-115.503 139.813-71.066 0-116.429-39.274-116.429-139.813V155.394zM425.351 166.617c0-18.235 14.024-30.865 33.195-30.865s33.195 12.63 33.195 30.865c0 17.764-14.024 30.391-33.195 30.391s-33.195-12.627-33.195-30.391m6.074 70.604h53.771v229.59h-53.771v-229.59z" />
                </svg>
            </div>
        </div>
    </ui-app>
    <script type="text/javascript" src="dist/runtime.js"></script>
    <script type="text/javascript" src="dist/scripts.js"></script>
    <script type="text/javascript" src="dist/polyfills-es5.js" nomodule></script>
    <script type="text/javascript" src="dist/main.js"></script>
</body>
</html>

Can someone please let me know what I am missing here?
FYI: I am trying to invoke rest api for UiPath Cloud Orchestrator Community Edition

The only thing I found is the headers content type and accept are missing. As media type is there, please try with accept header @sujivisva . Just assuming :slight_smile: