How to request a list of artifacts in a component using Python REST API?
I asked an earlier question about querying DNG to find the artifacts for a project, and realized I needed to include a specific OSLC request in my query. However I am still having issues getting any information other than the folder names/structure. I receive a 403: Forbidden error with every request I make, however I am fairly certain the authentication is working as I'm able to see these folders as well as some other protected information. I have also tried using a single session object to make the requests, with no change in results. Here is an example of a request I'm making to see the artifacts inside a component:
self.headers = {'Content-type': 'application/x-www-form-urlencoded', 'OSLC-Core-Version': '2.0', 'Accept': 'application/rdf+xml'}
info = {'oslc.select':'*' , 'oslc.where':'dcterms:identifier=123456' , 'oslc.prefix':'dcterms=https://ServerName/dc/terms/'}
encoded = urlencode(info, quote_via=quote_plus)baseURL = 'https://ServerName/rm/views?oslc.query=true&projectURL=https%3A%2F%2FServerName%2Frm%2Fprocess%2Fproject-areas%2F_1ipDAGUlEemksZVbt6XKiw&'
resp4_URL = baseURL + encoded
<Response [403]>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
<rdf:Description>
<err:detailedMessage rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>CRRRS1602W The operation is forbidden</err:detailedMessage>
<err:errorMessage rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
>Forbidden</err:errorMessage>
<err:errorStatus rdf:datatype="http://www.w3.org/2001/XMLSchema#long"
>403</err:errorStatus>
</rdf:Description>
</rdf:RDF>
Accepted answer
Hi Allison
https://jazz.ibm.com:9443/rm/views?oslc.query=true&projectURL=https%3A%2F%2Fjazz.ibm.com%3A9443%2Frm%2Fprocess%2Fproject-areas%2F__NDNJ0NcLEeqXpuBdEolY7wNOTE this doesn't end in &, where yours seems to - you need to confirm the full URL you are using is well-formed
https://jazz.ibm.com:9443/rm/views?oslc.pageSize=200&oslc.paging=true&oslc.prefix=dcterms%3D%3Chttp%3A%2F%2Fpurl.org%2Fdc%2Fterms%2F%3E&oslc.query=true&oslc.select=%2A&oslc.where=dcterms%3Aidentifier%3D3949&projectURL=https%3A%2F%2Fjazz.ibm.com%3A9443%2Frm%2Fprocess%2Fproject-areas%2F_NDNJ0NcLEeqXpuBdEolY7w
https://jazz.ibm.com:9443/rm/views
?oslc.pageSize=200
&oslc.paging=true
&oslc.prefix=dcterms=<http://purl.org/dc/terms/>
&oslc.query=true
&oslc.select=*
&oslc.where=dcterms:identifier=3949
&projectURL=https://jazz.ibm.com:9443/rm/process/project-areas/NDNJ0NcLEeqXpuBdEolY7w
Comments
4 other answers
Are you including a cookie store with your connection so that the authentication tokens are included in subsequent requests? Here's some sample code that gives some hints...
Comments
dcterms:identifier is of type xsd:string in the OSLC specification, and the OSLC query specification says strings have to be quoted in order to distinguish them from booleans, and numbers. So quoting the dcterms:identifier="330" should work and does for me. It also works without the quotes, but that is not following the OSLC standard.
Comments
Ian Barnard
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Dec 08 '20, 6:37 a.m.