microsoft / kiota-http-guzzle-php

Kiota Http request adapter implementation for PHP with Guzzle
https://aka.ms/kiota/docs
MIT License
4 stars 4 forks source link

sendAsync promise return nulls upon creation #112

Open sergioalborada opened 5 months ago

sergioalborada commented 5 months ago

When using the GuzzleRequestAdapter in the Microsoft Graph SDK, certain API calls (such as creating a team) return an empty result.

The problem is that the current implementation of sendAsync returns null for empty responses, even thought there may be important information in the headers.

So, in my opinioin, it should either return the raw response in those cases to allow us to read the headers when using the sdk, or either, attempt to build a valid response object from the response headers if the body is empty (at least, if the response code is 201 - Created).

Ndiritu commented 3 months ago

Hi @sergioalborada We support inspecting response and request headers for all requests using the request configuration options. Here's a sample:

$config = new UsersRequestBuilderGetRequestConfiguration();
$headersInspectionOption = new HeadersInspectionHandlerOption(true);
$config->options = [$headersInspectionOption];
$result = $graphServiceClient->users()->post($user, $config);

$responseHeaders = $headersInspectionOption->getResponseHeaders();

Let me know if this helps