Skip to Content
0
Aug 16, 2018 at 06:27 AM

Is it possible to log into B1 ServiceLayer with Cookies

2000 Views

Hi all,

i am trying to create a HTML5 Application which holds logged in ServiceLayer Session after reloading the Page.

If i log into the Service Layer using Postman i get following Header Details:

Connection →Keep-Alive
Content-Encoding →gzip
Content-Length →174
Content-Type →application/json;odata=minimalmetadata;charset=utf-8
DataServiceVersion →3.0
Date →Thu, 16 Aug 2018 06:10:06 GMT
Keep-Alive →timeout=15, max=100
Server →Apache
Set-Cookie →B1SESSION=0669e842-a11b-11e8-8000-000c29594cad;HttpOnly;
Set-Cookie →HASH_B1SESSION=4548D83BAFE012C7E2BA5E30A504D30B19CEC467; HttpOnly
Vary →Accept-Encoding

I tried accessing the Set-Cookie inside my JS Application to no avail.

My Login inside my JS Application looks like this:

			$.ajax({
				url: serviceLayerLoginURL,
				xhrFields: {
					withCredentials: true
				},
				data: jData = JSON.stringify({
				UserName: user,
				Password: pass,
				CompanyDB: comp
			}),
				type: "POST",
				dataType: "json",
				success: function (r, status, xhr) {
					app.SessionId = r.SessionId;
					app.to("tilesPage");
					sap.ui.core.BusyIndicator.hide();
				},
				error: this.onErrorCall
			});

Now my Question is: How do i access the right Information and how do i use them to Log in without the Username, Password and optional CompanyDB?