to do Splunk search with the help of API I am getting 404 error while doing this call
Firstly, I'm not sure if you can call the auth/login in such namespace.
The API reference says only about
https://<host>:<mPort>/services/auth/login
But more importantly, the auth/login endpoint only supports POST requests. You don't GET from it.
if I am trying this query with a post request I am getting unauthorized 401 error
Are you sending proper authentication data? https://docs.splunk.com/Documentation/Splunk/8.2.4/RESTREF/RESTaccess#auth.2Flogin
do you mean my creds?
Yes. As shown in the examples in docs.
Oh, and does your user have the role/capability to use API?
Are you able to get a response when you hit this as a plain curl request?