hkstKM
(HKST)
1
we use sonarcloud and all repos are private. I am trying to write a python script to pull list of projects on-boarded so far for scanning
r = requests.get(‘http://sonarcloud.io/api/projects/search?organization=my-org’,headers={'Authorization’: ‘’})
I get following error {‘errors’: [{‘msg’: ‘Insufficient privileges’}]}
could someone help pls.
thanks
HT
AlxO
(Alex Odoux)
2
Hi @hkstKM,
And welcome to the community! Here’s a snippet you could use.
You should definitely use https and provide a token.
I hope this helps!
#!/usr/bin/python3
import requests
url = 'https://sonarcloud.io/api/projects/search?organization=yourorganization'
token = 'yourtoken.....'
session = requests.Session()
session.auth = token, ''
call = getattr(session, 'get')
res = call(url)
print(res.status_code)
print(res.content)
1 Like
hkstKM
(HKST)
3
Thanks Alex - problem solved.
system
(system)
Closed
4
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.