Skip to content

axios call to localhost splunk 404 #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hgrbble1 opened this issue Aug 20, 2018 · 3 comments
Closed

axios call to localhost splunk 404 #66

hgrbble1 opened this issue Aug 20, 2018 · 3 comments

Comments

@hgrbble1
Copy link

hgrbble1 commented Aug 20, 2018

Hi I am using react.js and was wanting to use axios to make http request to the splunk rest api. I can curl my own local splunk with
curl -k https://localhost:8089/services/auth/login --data-urlencode username=admin --data-urlencode password=password
But when I try to do

`axios.post({
url: 'https://localhost:8089/services/auth/login',
data: {
username: 'username',
password: 'password'
}
})

    .then((response) => {
       console.log(response);
     })
     .catch((error) => {
       console.log(error);
       if (error.response) {
         console.log(error.response.data);
         console.log(error.response.status);
         console.log(error.response.headers);

       }
       else if (error.request) {
         console.log(error.request);
       }
       else {
         console.log('Error', error.message);
       }
       console.log(error.config);
     })`

I get a 404 error.
I am using free splunk when I am trying to connect.
Is the 404 error because of something to do with CORS?
I am also interested in maybe using the splunk javascript sdk but when I read about the related issue(#61) I have no idea where to start and how to use browserify.
Any help is much appreciated thanks!

@shakeelmohamed
Copy link
Contributor

Hi @hgrbble1, you should use the auth property instead of data to use basic auth with axios.

The 404 seems a bit odd, but is most likely related to CORS.

Click the link in my comment on #61, I have a short example of how to run browserify.

@hgrbble1
Copy link
Author

I can get a response back from the https call in postman when I turn off ssl. When ssl is turned on I can not get access to it. I am using free splunk on my laptop.

@shakeelmohamed
Copy link
Contributor

This issue doesn't seem related to the SDK according to you previous comment, please re-open if you find that the issue is related to the SDK specifically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants