Goal: I am trying to get code coverage, severity data from Sonarqube cloud.
I am making use of Postman to test Sonarqube webapi endpoints but not getting desired result.
(Note: Generated token in Sonarqube and provided it in Postman token_bearer)
example GET API:
Output: getting random HTML code, with 200 OK status
Desired output should be like below.
I have tried most of the endpoints, the result is same, random HTML code.
Below are some the API. I have tried,
(All get requests)
(Component key is optional)
What is the right way to consume the sonarqube endpoints?
Thanks in advance.
Welcome to the community!
You said “Sonarqube cloud”. I guess you mean SonarQube? If so, then what you’ve listed is correct. E.G. https://next.sonarqube.com/sonarqube/api/project_tags/search.
You say you keep getting random HTML code. Have you looked at what the returned page says? It may be relevant to your problem.
Thanks for your reply,
I analysed the response from the API, it does not have any valid information.
What is the correct way to call SonarQube web APIs from postman?
Thanks for your time.
I tried with Java code…
message attribute is empty.
The user token isn’t a bearer token, the SonarQube API uses HTTP basic authentication.
This is the recommended way. Benefits are described in the page User Token. The token is sent via the login field of HTTP basic authentication, without any password.
Used basic auth, the result is same.
Let’s back up. Log in to SonarQube with your browser and try calling the API directly (in your browser location bar). What do you get? Because based on the screenshots, it looks like you may be being redirected to the SonarQube app.
When I hit api directly in browser
It redirects to
Yes, you are right, it is redirected back to SonarQube app.
So to solve this issue, you’ll need to deal with the redirect. Then you should be able to use Postman without a problem.
Thanks for the reply,
Do you know on how to handle these redirects?
Any settings we need to change within Sonarqube
This isn’t happening within SonarQube. You probably need to talk to your network folks.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.