Suggested by Daniel Goehler – Needs Votes
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);
}
Status Details
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
Its a bit of joke really that to use cookies in AL we have to resort to using HttpWebRequest when MS have this on the HttpWebRequest page (HttpWebRequest Class (System.Net) | Microsoft Learn) " Important
We don't recommend that you use
HttpWebRequest
for new development. Instead, use the System.Net.Http.HttpClient class."This would be a really helpful feature as some APIs do not support other mechanisms than cookies.