I am trying to get a list of deliveries using this GET call:
https://datalink.hconnect.digital/api-products/basic#get-https-//api.hconnect.digital/ecs/v2/deliveries
Here is a picture if the link is broken in the future
If i var_dump the response i get this:
“tring(22) “��)�L
If i write the response into a txt file using file_put_contents i get this
謟 躋묩ൌ
Here is my code
$AuthJSON = include ("APIAuthenticator.php"); // retrieves the accesstoken with a POST request
$jsonObject = json_decode($AuthJSON, false);
$accessToken = $jsonObject->access_token;
$tokenType = $jsonObject->token_type;
$customerIdParameter = "?customerId=redacted";
$startDateParameter = "&startDate=2024-06-01";//"&startDate=".date('Y-m-d',strtotime("-1 days"));
$endDateParameter = "&endDate=".date('Y-m-d',strtotime("-1 days"));
// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.hconnect.digital/ecs/v2/deliveries".$customerIdParameter.$startDateParameter.$endDateParameter);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$headers = array();
$headers[] = 'Accept: application/json';
$headers[] = 'Content-Type: application/json; charset=utf-8';
$headers[] = 'Authorization: '.$tokenType.' '.$accessToken;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
var_dump($result);
file_put_contents("GetDeliveriesList_Output.txt", $result);
//return $resultObject;
When i try the API Call in Postman i get the correct JSON with all deliveries.
Also i tried it with Talend at first using the tRESTClient component.
Which looks like this
The output in Talend looks like this
In my php script i tried to convert the encoding to utf-8 from different ones but i only get different gibberish everytime.
Pascal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.