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.
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.
Edit after comments:
These are the response Headers
'string(480) "HTTP/2 200date: Tue, 09 Jul 2024 11:18:10 GMTcontent-type: application/json; charset=utf-8vary: Accept-Encodingstrict-transport-security: max-age=15724800; includeSubDomainsx-content-type-options: nosniffx-frame-options: SAMEORIGINx-xss-protection: 1; mode=blockcontent-encoding: gzipx-request-id: d7bd9ad9a947fd97ee68e953dc72a9d8x-azure-ref: 20240709T111810Z-17cf9458cfbljplp9z04nke6fc00000007sg0000000164kkx-cache: CONFIG_NOCACHE'
After addingcurl_setopt($ch, CURLOPT_ENCODING, '');
The output is string(2) "[]"
Even though it should be a json Array