Splunk Dev

How to use Splunk JavaScript SDK to return SID from Splunk search?

ssharm02
Explorer

Hi,
I am trying to use the Splunk JavaScript SDK in order to return a SID from a search. I used the code that's provided in the documentation or mentioned in the forum.
```

      let http = new splunkjs.JQueryHttp();
      let service = new splunkjs.Service(http,{
      username: "@#$@#$",
      password: "@#$@#",
      scheme: "https",
      host: "digitalsplunk.test.com/services/search/jobs",
      port: "8089",
      version: "7.1.0"
    });

    // First, we log in
    service.login(function (err, success) {
      // We check for both errors in the connection as well
      // as if the login itself failed.
      if (err || !success) {
        console.log('error is ' + err)
        console.log(
          "Login failure. Please check your server hostname and authentication credentials."
        );
        //done(err || "Login failed");
        console.log('logon failure')
        return;
      } else  if (success) {
        console.log('logon successful')
      }```

This code messes up the URL. This is what the url looks like using the search object
https://digitalsplunk.test.com/services/search/jobs:8089/services/auth/login?output_mode=json
And this is what it should look like
https://digitalsplunk.test.com:8089/services/search/jobs?output_mode=json

I also tried making an angular service (without the Splunk SDK) and made a post request, it didn't work either. If anyone could help me fetch the SID, I would greatly appreciate it

Labels (2)
0 Karma
1 Solution

ssharm02
Explorer

I ended up using node js to solve this issue. The javascript sdk just wasn't working (maybe due to corporate security issues)

View solution in original post

0 Karma

ssharm02
Explorer

I ended up using node js to solve this issue. The javascript sdk just wasn't working (maybe due to corporate security issues)

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...