Issue with getWhatsAppMediaMetadataResponse Returning Null
I am trying to retrieve the metadata of a media file using the getWhatsAppMediaMetadata function. However, the function returns a getWhatsAppMediaMetadataResponse that is null. I am unsure if I am missing something in my implementation or if this is a bug in the function.
- Original code
private function getWhatsAppMediaMetadataResponse(ResponseInterface $response, UriInterface $requestUri): mixed
{
$statusCode = $response->getStatusCode();
$responseBody = $response->getBody();
$responseHeaders = $response->getHeaders();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf('[%d] API Error (%s)', $statusCode, $requestUri),
$statusCode,
$responseHeaders,
$responseBody
);
}
$responseResult = null;
return $responseResult;
}
- Recommended code
private function getWhatsAppMediaMetadataResponse(ResponseInterface $response, UriInterface $requestUri): mixed
{
$statusCode = $response->getStatusCode();
$responseBody = $response->getBody();
$responseHeaders = $response->getHeaders();
if ($statusCode < 200 || $statusCode > 299) {
throw new ApiException(
sprintf('[%d] API Error (%s)', $statusCode, $requestUri),
$statusCode,
$responseHeaders,
$responseBody
);
}
return $responseHeaders;
}
Hi @andre-hoffmann, thank you very much for the reported issue and I'm very sorry for the late reply. You are correct, there's an issue when processing this HEAD request within the library. We'll model it properly and provide the correct data as a result. I'll label this issue with the next patch version and we'll provide the fix soon.
In the meantime, feel free to call our API directly: https://www.infobip.com/docs/api/channels/whatsapp/whatsapp-inbound-messages/get-whatsapp-media-metadata.
Best regards, Filip
Hi @ib-fsrnec,
Thank you so much for your feedback! 😊 I truly appreciate it and will gladly wait for the update to the package, as I am fully relying on it for my implementation.
Looking forward to the improvements!
Hi @andre-hoffmann,
The issue should be fully fixed with the version 6.2.1 that was released last week. The usage example can be found in the following test. The method now returns an array with the keys corresponding to relevant headers as documented here.
Please let us know if the solution works for you!
Best regards, Filip
Hi @ib-fsrnec,
Thank you so much! I can confirm that the issue has been fixed :)