cancel
Showing results for 
Search instead for 
Did you mean: 

Restful API login --- logonToken returning null....what am I doing wrong?

Former Member
0 Kudos

I wrote following code in JavaScript to logon.

Problem is that the LogonToken is returning 'null'.

var invocation = new XMLHttpRequest();

var url = 'http://<server>:6405/biprws/logon/long';

    var body ='{userName:"xxx", password: "xxx", auth: "secEnterprise"}';

     invocation.open('POST', url, true);

     invocation.setRequestHeader('X-PINGARUNER', 'pingpong');

     invocation.setRequestHeader('Content-Type', 'application/json');

     invocation.setRequestHeader('Accept', 'application/json');

     invocation.send(body);

     token = invocation.getResponseHeader('X-SAP-LogonToken');

     console.log(token);

I used this useful tutorial here.

My tests with Restful API + Javascript - Sample No 1

I changed false to true because I get following error message:

Synchronous XMLHttpRequest on the main thread is deprecated

Do you think this is  the reason why it is returning null?

Thanking you in advance...

Accepted Solutions (1)

Accepted Solutions (1)

former_member197386
Active Contributor
0 Kudos

Hello Hayden,

It could be interesting to look at the developer tools of your web browser, or using Fiddler or Wireshark to analyse the HTTP traffic.

Most of the time, Javascript calls are done in an asynchronous way and the result is provided to a callback function at the end (in case of success or error).

Regards,

Anthony

Former Member
0 Kudos

I use Chrome and click inspect

I get this error message and code is:

invocation.open('POST', url, false);

former_member197386
Active Contributor
0 Kudos

Did you look to Network Trafic tab?

Former Member
0 Kudos

Hi thank you.

do you mean this...?

It does not show any error...

former_member197386
Active Contributor
0 Kudos

Ok, that means the call is not triggered at all. The issue is from JavaScript side. Did you try libraries like jQuery?

Anthony

Former Member
0 Kudos

Thank you. I will try different code using JQuery to see what happens! I really appreciate your advice...

Answers (0)