readdle / app-store-server-api

Pure PHP library that allows managing customer transactions using the App Store Server API and handling server-to-server notifications using the App Store Server Notifications V2
MIT License
53 stars 20 forks source link

Get response text when failed with status code 400. Response text is: " " #27

Open popraul98 opened 2 weeks ago

popraul98 commented 2 weeks ago

We extended the library with a new functionality and we faced some errors and we are not getting any response text to help us. Auth is working as we are using this for something else, we have issues seeing the detailed errors.

{ "errors": "HTTP request [PUT https://api.storekit-sandbox.apple.com/externalPurchase/v1/reports] failed with status code 400. Response text is: " }

Is there a way to enable advance debugging? do you have any input how do we surface the real errors Apple returns?

pkotets commented 1 week ago

Hello,

Well, considering that it's 400 error, I guest file_get_contents (which is currently used as an HTTP transport) returns false and that's why there is empty string. It's just my guess, though.

There is no advanced debug mode in the library, however you can play around in HTTPRequest::performRequest(), that's where the request is actually performed.

Also, I am working on a new version of the library, there will be a separate HttpRequest and HttpResponse classes, so it would be possible to get all the information, but I have no ETA ATM, probably 2-3 weeks or so.