• ×
    Information
    Windows update impacting certain printer icons and names. Microsoft is working on a solution.
    Click here to learn more
    Information
    Need Windows 11 help?
    Check documents on compatibility, FAQs, upgrade information and available fixes.
    Windows 11 Support Center.
  • post a message
  • ×
    Information
    Windows update impacting certain printer icons and names. Microsoft is working on a solution.
    Click here to learn more
    Information
    Need Windows 11 help?
    Check documents on compatibility, FAQs, upgrade information and available fixes.
    Windows 11 Support Center.
  • post a message
Guidelines
The HP Community is where owners of HP products, like you, volunteer to help each other find solutions.
HP Recommended

Running into a strange issue with the REST API to make a call. So from Postman I am able to have the call request complete successfully. I created a php script that can run the same request via curl and have it complete successfully, which is below. When I try to run it through ajax using the code below, the call fails. The debug log is not very helpful, it only says the REST call failed, not why. In the PHP code I needed to have it ignore the SSL when accessing the https://PolycomIP in order to access the REST API successfully. The debug log does occasionally say that "authentication failed" when attempting to access via AJAX, but not every time a request is made. Can someone help me to understand why the REST request is failing using AJAX? I am using the same auth key generated by Postman.

 

Error log:

 

1028122807|rest |0|00|At wappRestApiHandlerC::Handle. Moved REST API to request processing mode.
1028122807|rest |0|00|At wappRestApiHandlerC::Handle. Request's HTTP method POST
1028122807|rest |0|00|At wappRestApiHandlerC::Handle. processRequest function failed.

 

AJAX:

var xmlhttp = new XMLHttpRequest();

var json = { "data":
{
"Dest": request.number,
"Line": 1,
"Type": "TEL"
}
};

xmlhttp.open("POST", request.url);
xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xmlhttp.setRequestHeader("Authorization", "Basic **AUTH ENCODED FROM POSTMAN**");
xmlhttp.send( JSON.stringify(json) );

PHP:

<?php

if(isset($_GET['number'])){ $numbero = $_GET['number'];}
if(isset($_POST['number'])){ $numbero = $_POST['number'];}
if(isset($_POST['ip'])){ $ip = $_POST['ip'];}
if(isset($_GET['ip'])){ $ip = $_GET['ip'];}
if(isset($_POST['user'])){ $username = $_POST['user'];}
if(isset($_GET['user'])){ $username = $_GET['user'];}

$numbero = preg_replace("/[^0-9]/", "", $numbero);

echo($numbero);

$curl = curl_init();
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt_array($curl, array(
CURLOPT_URL => "https://".$ip."/api/v1/callctrl/dial",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"{\r\n \"data\":{\r\n \"Dest\": ".$numbero.",\r\n \"Line\": 1,\r\n \"Type\": \"TEL\"\r\n }\r\n}",
CURLOPT_HTTPHEADER => array(
"Authorization: Basic **AUTH GENERATED BY POSTMAN**",
"Content-Type: application/json"
),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
?>
<script type='text/javascript'>
self.close();
history.go(-1);
</script>
1 REPLY 1
HP Recommended

Is there a way to get more detail out of the Polycom logs so I can understand what part of the call is failing?

† The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the <a href="https://www8.hp.com/us/en/terms-of-use.html" class="udrlinesmall">Terms of Use</a> and <a href="/t5/custom/page/page-id/hp.rulespage" class="udrlinesmall"> Rules of Participation</a>.