最近我开始使用 sonarcloud,我被要求为一个大学项目提取项目的技术债务。我正在尝试使用由 sonarcloud 公开的 Web API,但收效甚微。这是我写的python代码
import requests
import json
r = requests.get ('https://sonarcloud.io/component_measures?id=Huginn87_jabref/api/metrics/component?component=&metricKeys=sqale_index',auth= (' usr ',' pwd '))
code = r.status_code
print "Status code:", code
print r.json ()
这就是我得到的结果
Status code: 200
Traceback (most recent call last):
File "test.py", line 7, in <module>
print r.json ()
File "/home/usr/.local/lib/python2.7/site-packages/requests/models.py", line 897, in json
return complexjson.loads (self.text, ** kwargs)
File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
return _default_decoder.decode (s)
File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
obj, end = self.raw_decode (s, idx = _w (s, 0) .end ())
File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
raise ValueError ("No JSON object could be decoded")
ValueError: No JSON object could be decoded
根据文档,您应该给我一个 json 格式,但事实并非如此。有人好心告诉我哪里错了吗?提前谢谢了。问候。