document the use of the headersinspection handler and the options.
andrueastman opened this issue · comments
Related to microsoft/kiota#2963
We should add samples of reading request/response headers in the languages supported.
In C# this looks to be close to
var headersInspectionHandlerOption = new HeadersInspectionHandlerOption()
{
InspectResponseHeaders = true // specific you wish to collect reponse headers
};
//add the option
var user = graphClient.Users["user-id"].GetAsync(requestConfiguration => requestConfiguration.Options.Add(headersInspectionHandlerOption));
//use the key to get the header.
var locationHeader = headersInspectionHandlerOption.ResponseHeaders["Location"];
Is there a way to make a custom request with that Location URL that is returned? We'd want the Auth passed from the existing graphClient - but i don't see a way to make a custom request - i'd have to create a new HttpClient which is duplicative.
Piggybacking here, in python it would be something like:
from kiota_http.middleware import HeadersInspectionHandler
headers_handler = HeadersInspectionHandler()
and then after the request is made, you can get, say, the location
from the response headers as such:
headers_handler.options._response_headers._headers['location']
@andrueastman I've just tried your code in a csharp project and must be missing something, because both the ResponseHeaders
and RequestHeaders
are empty after the request result is returned.
Are there additional steps when creating the client with kiota to enable the header-inspection functionality?