QuickBooks-V3-PHP-SDK
QuickBooks-V3-PHP-SDK copied to clipboard
No way to retrieve response headers from IntuitResponse
If a request happens and it gets throttled by QuickBooks there is no way to grab the headers from the response, specifically "Retry-After". The response object is not returned, instead a status code and body is.
Without this header my application can not wait the appropriate amount of time to send the request again, so we end up spamming QuickBooks.
$intuitResponse = $this->httpClientInterface->makeAPICall($requestUri, $HttpMethod, $httpHeaders, $requestBody, null, true);
$faultHandler = $intuitResponse->getFaultHandler();
$this->LogAPIResponseToLog($intuitResponse->getBody(), $requestUri, $intuitResponse->getHeaders(), false);
//Based on the ducomentation, the fetch expected HTTP/1.1 20X or a redirect. If not, any 3xx, 4xx or 5xx will throw an OAuth Exception
//for 3xx without direct, it will throw a 503 code and error saying: Invalid protected resource url, unable to generate signature base string
if($faultHandler) {
if($throwExceptionOnError == true){
throw new ServiceException("Request is not made successful. Response Code:[" . $faultHandler->getHttpStatusCode() . "] with body: [" . $faultHandler->getResponseBody() . "].", $faultHandler->getHttpStatusCode());
}else{
$this->faultHandler = $faultHandler;
return null;
}
}else{
$this->faultHandler = false;
}
return array($intuitResponse->getStatusCode(),$intuitResponse->getBody());
Maybe you can amend this PR it adds Intuit: https://github.com/intuit/QuickBooks-V3-PHP-SDK/pull/186
I'll add functionality to grab headers on another PR
Any update on this? I'm wanting to get the max results so I know whether to page for more results. With the DataService
, looks like I need to get the restHandler
to get to the intuitResponse
object. Looks like for the interim, I will create my own that extends so I can get access to the private/protected values.
Eg, I call Query which always returns the serialised response, which normally is fine. But I think I'm hitting a 500 result per page limit so I need to know this & set max and first position values.