Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
jcampbel1
Contributor II
Contributor II

Get 404 error while trying to send a request to https://my-tenant.us.qlikcloud.com/api/v1/users/me

I am getting an error when I call the endpoint https://my-tenant.us.qlikcloud.com/api/v1/users/me in my code ( I use my company tenant instead of https://my-tenant.us.qlikcloud.com in my code.)

    try {
      const userInfoUrl = 'https://my-tenant.us.qlikcloud.com/api/v1/users/me';
      const response = await fetch(userInfoUrl, {
        method: 'GET',
        headers: {
          'Authorization': `Bearer ${token}`,
        },

 
I have confirmed that I pass in a valid token (I get token when logging in).

When I go to the endpoint https://my-tenant.us.qlikcloud.com/api/v1/users/me in google, it works. So why doesn't it work in my code?

Thanks

Labels (3)
4 Replies
alex_colombo
Employee
Employee

What are you trying to achieve?
/api/v1/users/me endpoint will trigger e redirect, that's why it works in browser and not from your code.

Levi_Turner
Employee
Employee

I am not a JavaScript guy so hopefully the code is usable as a base, but I can't explain a 404. Considerations:

- /api/v1/users/me will return a 301 and redirect you to /api/v1/users/{user_id}.

- You're not specifying where the bearer token is coming from. In my code I am using an API key from Qlik Cloud. Removal of the "Developer" role will result in a 401 (pre-auth unauthorized), which makes sense. Still not 404. Are you using a JWT IDP to generate the bearer token?

Example code which works on my tenant:

var https = require('https');

var options = {
   hostname: '<my_tenant>',
   port: 443,
   path: '/api/v1/users/me',
   method: 'GET',
   headers: {
      'Authorization' : ' Bearer <my_api_key>'
   }
};

https.get(options, function(response) {
   console.log("Got response: " + response.statusCode);
   response.on("data", function(chunk) {
      console.log("BODY: " + chunk);  
   });
   }).on('error', function(e) {
      console.log("Got error: " + e.message);
});
 

 

jcampbel1
Contributor II
Contributor II
Author

i am creating a POC type of project. I need to login via oauth (which works as I am returned back a token and redirected) once on the page '/homepage' I want to call that endpoint that however when the endpoint is being called using the code shown above with a valid token. I am getting the 404 error

jcampbel1
Contributor II
Contributor II
Author

hello, thanks for the reply. I am using the access token returned to me after the user is authenticated via Oauth. in my code I use /api/v1/users/me endpoint however when I look in the console logs of the error it shows me  /api/v1/users/{user_id} - this means it actually knows what id is associated with the token however I am still getting that 404 error. 

I dont use a API whatsoever because what is supposed to happen in the flow of is:

1. user logs in via oauth
2. user now has access token
3. user directed to homepage
4.using the endpoint /api/v1/users/me I want to get information such as email, firstname etc so I can display.

Later on I want to be able to get a list of apps they have access to etc