<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Splunk NodeJS module not giving a successful login against Splunk cloud in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-NodeJS-module-not-giving-a-successful-login-against/m-p/695892#M11635</link>
    <description>&lt;P&gt;We are using &lt;STRONG&gt;Splunk cloud&lt;/STRONG&gt; in our enterprise and as part of an automation project we want programatic way for doing Splunk search. Based on Splunk website we found that there is node module splunk-sdk (&lt;A href="https://www.npmjs.com/package/splunk-sdk" target="_blank" rel="noopener"&gt;https://www.npmjs.com/package/splunk-sdk&lt;/A&gt;) using which we can access Splunk even though the module is not mentioning explicitly anything about Splunk cloud.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Following is the code we attempted but its failing to connect. Would like to know if any special configuration needs to be done in order to achieve the connection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;(async=&amp;gt;{
let splunkjs = require('splunk-sdk');

let service  = new splunkjs.Service({username: "myusername", password: "***"});


async function myFunction() {
  try {
    await service.login();
    console.log("Login was successful: " + success);
    let jobs = await jobs.fetch();
    let jobList = jobs.list();
    for(let i = 0; i &amp;lt; jobList.length; i++) {
        console.log("Job " + i + ": " + jobList[i].sid);
    }
} catch(err) {
    console.log(err);
}  &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Following is the error we are getting.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ab73863_0-1723255897649.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/32160iFE7862A38582DBB3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ab73863_0-1723255897649.png" alt="ab73863_0-1723255897649.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Please help in understanding and resolving this issue if anyone has encountered the same issue.&lt;/P&gt;</description>
    <pubDate>Sat, 10 Aug 2024 02:15:07 GMT</pubDate>
    <dc:creator>ab73863</dc:creator>
    <dc:date>2024-08-10T02:15:07Z</dc:date>
    <item>
      <title>Splunk NodeJS module not giving a successful login against Splunk cloud</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-NodeJS-module-not-giving-a-successful-login-against/m-p/695892#M11635</link>
      <description>&lt;P&gt;We are using &lt;STRONG&gt;Splunk cloud&lt;/STRONG&gt; in our enterprise and as part of an automation project we want programatic way for doing Splunk search. Based on Splunk website we found that there is node module splunk-sdk (&lt;A href="https://www.npmjs.com/package/splunk-sdk" target="_blank" rel="noopener"&gt;https://www.npmjs.com/package/splunk-sdk&lt;/A&gt;) using which we can access Splunk even though the module is not mentioning explicitly anything about Splunk cloud.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Following is the code we attempted but its failing to connect. Would like to know if any special configuration needs to be done in order to achieve the connection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;(async=&amp;gt;{
let splunkjs = require('splunk-sdk');

let service  = new splunkjs.Service({username: "myusername", password: "***"});


async function myFunction() {
  try {
    await service.login();
    console.log("Login was successful: " + success);
    let jobs = await jobs.fetch();
    let jobList = jobs.list();
    for(let i = 0; i &amp;lt; jobList.length; i++) {
        console.log("Job " + i + ": " + jobList[i].sid);
    }
} catch(err) {
    console.log(err);
}  &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Following is the error we are getting.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ab73863_0-1723255897649.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/32160iFE7862A38582DBB3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ab73863_0-1723255897649.png" alt="ab73863_0-1723255897649.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Please help in understanding and resolving this issue if anyone has encountered the same issue.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Aug 2024 02:15:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-NodeJS-module-not-giving-a-successful-login-against/m-p/695892#M11635</guid>
      <dc:creator>ab73863</dc:creator>
      <dc:date>2024-08-10T02:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk NodeJS module not giving a successful login against Splunk cloud</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-NodeJS-module-not-giving-a-successful-login-against/m-p/695915#M11637</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/271033"&gt;@ab73863&lt;/a&gt;- Try this approach with sessionKey.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VatsalJagani_0-1723369459905.png" style="width: 738px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/32162i81BA9C59BD2312F4/image-dimensions/738x501?v=v2" width="738" height="501" role="button" title="VatsalJagani_0-1723369459905.png" alt="VatsalJagani_0-1723369459905.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Specify Splunk Cloud URL and port number should be 8089 but you can confirm with your Splunk Cloud Representative or Splunk Cloud Support.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps!!!&lt;/P&gt;</description>
      <pubDate>Sun, 11 Aug 2024 09:45:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-NodeJS-module-not-giving-a-successful-login-against/m-p/695915#M11637</guid>
      <dc:creator>VatsalJagani</dc:creator>
      <dc:date>2024-08-11T09:45:29Z</dc:date>
    </item>
  </channel>
</rss>

