I am a newbie to python and api queries. However, I am learning python automation in the process. Request your kind help here.
I have a SonarQube API call through which I fetch some metrics or values as a JSON response on my browser. I read that curl or through requests module in python, we would be able to download the response into a variable or file. How much ever I try, I am not able to do through a program. Right now, I am hard coding it in a variable and proceeded with my next steps. Can someone help me here.
Query I use:
https://sonar.com:9000/sonar/api/measures/component?component=abcdef&branch=test&metricKeys=ncloc
I get JSON response like this on the browser:
"component": {
"id": "AXK4GYajYOT4RM44Ji",
"key": "abcdef",
"name": "test",
"qualifier": "TRK",
"measures": [
{
"metric": "ncloc",
"value": "100000"
}
],
"branch": "test"
}
}
My intention is to store all of this in a python variable.