Error: (406) Not Acceptable when fetching workitem info via OSLC
I'm writing a Java application to fetch the list of all workitems (Id and Title) for a given Project Area via OSLC.
These are the detailed steps I did (in java application):
- Send HTTP GET Request for https://<server>:9443/ccm/rootservices
- no authentication is required
- returns response with XML stream
- Parse the response XML stream
- Using the xpath (/rdf:Description/oslc_cm:cmServiceProviders/@rdf:resource)
- Extract all cmServiceProviders catalogs
=> returns https://<server>:9443/ccm/oslc/workitems/catalog
- Send HTTP GET Request for https://<server>:9443/ccm/oslc/workitems/catalog
- response: authRequired
- post authentication form with login credentials
=> authentication successful
- Send HTTP GET Request for https://<server>:9443/ccm/oslc/workitems/catalog once again
=> returns response with XML stream
- Parse the response XML stream
- Using the xpath (//oslc:ServiceProvider)
- Extract my Project area and its corresponding services link
=> returns https://<server>:9443/ccm/oslc/contexts/<ID>/workitems/services.xml for my project area
- Send HTTP GET Request for https://<server>:9443/ccm/oslc/contexts/<ID>/workitems/services.xml
- response: authRequired
- post authentication form with login credentials
=> authentication successful
- Send HTTP GET Request for https://<server>:9443/ccm/oslc/contexts/<ID>/workitems/services.xml again
- post authentication form with login credentials
we are getting this error
=> HTTP/1.1 406 Not Acceptable [X-Powered-By: Servlet/3.0, x-com-ibm-team-scenario: 10.118.58.5, Cache-Control: private, max-age=0, must-revalidate, Expires: Fri, 02 Aug 2019 09:45:20 GMT, Content-Language: en-IN, Content-Length: 0, Connection: Close, Date: Fri, 02 Aug 2019 09:45:21 GMT]
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Why there is an “Error: (406) Not Acceptable” from the server at the last step ??
My internet searches told me to look into my request’s accept header to look for any incompatible data with the server. But It is not clear to me what is going wrong with the accept header ?
Also, the same authentication has worked for the previous GET requests like:
https://<server>:9443/ccm/oslc/workitems/catalog
https://<server>:9443/ccm/oslc/contexts/<ID>/workitems/services.xml
Then, why the same authentication fails for the GET request for:
https://<server>:9443/ccm/oslc/contexts/<ID>/workitems
Could you please help ? Thanks in advance.
One answer
1. See https://rsjazz.wordpress.com/2019/05/13/using-a-rest-client-to-authenticate-to-elm-clm-applications/ and understand authentication
2. I authenticated and then followed your steps with Postman and I received correct data (even leaving out the accept and the oslc header in the beginning)
Comments
- You do not send a body in the GET. You do only have to authenticate once and then the cookies and other headers should be enough.
- Use Lyo see https://eclipse.googlesource.com/lyo/org.eclipse.lyo.client/+/refs/heads/master/org.eclipse.lyo.client.java.sample/src/main/java/org/eclipse/lyo/client/oslc/samples/RTCFormSample.java look into https://rsjazz.wordpress.com/2019/03/07/type-system-manager-part-2/ and go to the Jazz.net articles the last one has some information about how to get started with Lyo.
Comments
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Aug 02 '19, 5:27 a.m.How should I ask a question in the Forum if I want to receive useful answers?
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Aug 02 '19, 6:13 a.m.What are the request headers you send with the GET?
Kalyani Deshmukh
Aug 02 '19, 6:20 a.m.1."Accept", "application/rdf+xml"
These headers we are sending with the GET request.