HTTP request with cookies

Hi,
I am trying to get our auth process to work, which requires me to send a session cookie from the AppGyver to our backend. How can I achieve that? I am trying to set http header “Cookie” with the value"session=123456", but in the chrome debug console this request is shown without any cookies.


unknown

It says your method is ‘GET’. Shouldnt this be PUT or POST?

Nope, it should be GET. Its working in postman.

I did a quick check and my feeling is that it does not work with a header key called “cookie”. Did you try to rename it to something else to see whether it appears then?
If yes, then I assume its something the AppGyver team needs to look into.

1 Like

Yes, everything else, like “cookiex” is sent as expected.

FYI - Reported Cookie header is not sent | Voters | AppGyver

Anyone has a solution to this topic (i.e. sending header with cookie)?
Please, I need for my project !!!

Thanks
Luca Brescancin

Hello, is there any update on this topic? Thanks

Unfortunately there is no update :confused: For future reference, the tracker ticket will be updated when it is fixed. Please upvote the linked tracker ticket.

Hi Ondrej_Nekvinda

I’m currently facing the same issue with SAP Business One Service Layer, but i’ve found a workaround. The key is, on every request, you will need to send the Databasename, Username and password in an Authorization-Header as type Basic.
Same Logic is used with Extensions on Webclient…

As an Example: i have an App with a Log in Page an a page for getting Items after press a button.

Workaround:
Create an variable in APP VARIABLES called “connectionString”

created PAGE VARIABLES in the Log in Page called “companyDb”, “password”, “userName”.

The logic after press the Log in Button is simple:
You have to encode the login credentials to base64 with an JS-script an store the result in the APP VARIABLE “connectionString”.

connectionString

{“CompanyDB”: “<DatabaseName>”,“UserName”: “<UserName>”}:<password>)

JS-Script

return { result: “Basic " + encodeBase64(”{" + ‘“CompanyDB”’ + “: " + '”’ + inputs.companydb + ‘"’ + “,” + ‘“UserName”’ + “: " + '”’ + inputs.username + ‘"’ +"}" + “:” + inputs.password) };
function encodeBase64(data) {
console.log(‘data’, data)
if (typeof btoa === “function”) {
return btoa(data);
} else if (typeof Buffer === “function”) {
return Buffer.from(data, “utf-8”).toString(“base64”);
} else {
throw new Error(“Failed to determine the platform specific encoder”);
}
}

For every following request you can send an HTTP-Header <Authorization> with the stored variable.
Maybe you have to modify the b1s.conf-file to allow the Authorization-Header.

Cheers
Benjamin

1 Like

Hi Benjamin,
we ended up doing something similar based on the answer from Trinidad in Service Layer without cookies | SAP Community.
It is not a perfect solution, but it works for basic needs. There is an issue when basic auth does not work properly on custom views (SQL and HANA) though, but that will be fixed in Feature Package 2202 of SAP Business One 10.0.

Hi Ondrej

Thank you for your feedback. I agree with you, it’s not the perfect solution.
Let’s hope AppGyver fixes the Cookies header issue quickly.