4

I am trying to connect to bing ads soap api using node-soap. I have created the request as suggested in bing documentation. But each time I try to connect the response states the Invalid credentials (Error code - 105) Message - Authentication failed. Either supplied credentials are invalid or the account is inactive.

I was able to authenticate the API using sample C# code provided by bing. So, its clear that the credentials/token are working perfectly fine.

Is there a way to identify the issue with my approach or in my node code.

soap.createClient(url, function (err, client) {
    if (err) {
        console.log("err", err);
    } else {
        client.addSoapHeader({
            'AuthenticationToken': '<AuthenticationToken>',
            'DeveloperToken': '<DeveloperToken>',
            'CustomerId': '<CustomerId>',
            'CustomerAccountId': '<CustomerAccountId>',
        });        
        client.SubmitGenerateReport(args, function (err, result) {
            if (err) {
                console.log("err", err.body);
            } else {
                console.log(result);
            }
        });
    }
});

PS: Bing Documentation Sucks. Hail Stackoverflow!

Dpk
  • 41
  • 1
  • 4
  • Did you got it working and do you mind sharing how? thanks – Christoph Feb 25 '18 at 14:49
  • Did you, or did @Christoph get it working, and do you mind sharing now? – Amit May 27 '18 at 07:48
  • @amit, unfortunately I did not. I am working with other tools now to access the api since I primarily needed it for analysis. – Christoph May 28 '18 at 08:28
  • @Christoph, Sorry for the delayed response. Yup, I got it working. When I compared my request xml with the request xml generated with WcfTestClient, I found my request wasn't properly formatted. On fixing that I was able to call the API. I hope that helps :) – Dpk May 28 '18 at 09:05
  • Thanks, I managed to get it working with the answer posted to this question. – Amit May 28 '18 at 09:52
  • @Dpk can you share your full code if possible. how you generate AuthenticationToken, is there any node js way to generate ? – Yusuf Khan Jun 28 '20 at 08:48

1 Answers1

5

You need to prefix each key in your headers with tns, e.g: tns:AuthenticationToken

radyz
  • 1,664
  • 1
  • 17
  • 26