15
Could you please add HttpClientHandler with UseCookies = false to your AL wrapper of the .Net class HttpClient to allow to set cookies?

There are APIs like Qlik Sense (https://help.qlik.com/en-US/sense-developer/November2019/Subsystems/Platform/Content/Sense_PlatformOverview/Integration/expose-qlik-sense.htm) who uses Cookies for Authentication. We are currently not able to use those APIs in the Cloud, because HttpClient by default don't transfers the header "Cookie". All other header can be set and will be transferred.

C# Console Example:

var handler = new HttpClientHandler { UseCookies = false };
using (var client = new HttpClient(handler))
{
client.DefaultRequestHeaders.Add("Cookie", "cookiename=value");
var response = await client.GetAsync("https://server/api");
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
Category: Development
STATUS DETAILS
Needs Votes
Ideas Administrator

Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we will consider it in the future.

Best regards,
Business Central Team

Comments

D

AL Example, where the HTTP header "TestHeader" will be transferred to the server, but the HTTP header "Cookie" not.

trigger OnAction()
var
WebClient: HttpClient;
ResponseMessage: HttpResponseMessage;
Response: Text;
begin
WebClient.DefaultRequestHeaders.Add('TestHeader', 'cookiename=value');
WebClient.DefaultRequestHeaders.Add('Cookie', 'cookiename=value');
WebClient.Get('https://server/api', ResponseMessage);
ResponseMessage.Content().ReadAs(Response);
Message(Response);
end;

Category: Development