It's all about the answers!

Ask a question

Error: (406) Not Acceptable when fetching workitem info via OSLC from C#.NET application


Karthikeyan Baskaran (45813) | asked Jul 02 '14, 9:24 a.m.

I'm writing a C#.NET 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 C#.net 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
         => returns response with XML stream
-    Parse the response XML stream
      - Using the xpath (//oslc:QueryCapability/oslc:queryBase/@rdf:resource)
      - Extract the work item query
         => returns https://<server>:9443/ccm/oslc/contexts/<ID>/workitems
-    Send HTTP GET Request for https://<server>:9443/ccm/oslc/contexts/<ID>/workitems
      - response: authRequired
      - post authentication form with login credentials
            => System.Net.WebException: The remote server returned an error: (406) Not Acceptable.at System.Net.HttpWebRequest.GetResponse()
------------------------------------------------------------------------------------------------------------------------------------------------
Why there is an “Error: (406) Not Acceptable” from the server at the last authentication 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.


Comments
Donald Nong commented Jul 03 '14, 12:36 a.m.

I can easily reproduce the HTTP 406 error when I remove the necessary HTTP Request Headers. These are required.

Accept: application/rdf+xml
OSLC-Core-Version: 2.0
If you prefer, you can also use "Accept: application/json", which will give you a response in JSON format.

2 answers



permanent link
Karthikeyan Baskaran (45813) | answered Jul 31 '14, 4:33 a.m.
Located the problem.
------------------------------------------------------------------------------------------------------------------------------------
Send HTTP GET Request for https://<server>:9443/ccm/oslc/contexts/<id>/workitems
      - response: authRequired
      - post authentication form with login credentials
            => System.Net.WebException: The remote server returned an error: (406) Not Acceptable.at System.Net.HttpWebRequest.GetResponse()
------------------------------------------------------------------------------------------------------------------------------------
During this step, 2 requests are involved. First request is the GET request for the URL and second one is the POST request for authentication.
The first request already had proper Accept format in its header whereas the second one didn't.

Copying the Accept format from the first request and also providing the same for the second request solved the problem.

Though I don't understand why the previous steps were all successful (even in those steps, authentication request was sent with missing accept header), my current issue is solved. Thanks.

Comments
Ralph Schoon commented Jul 30 '19, 3:31 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

The accept header are required for OSLC, but they are not for the authentication. See https://rsjazz.wordpress.com/2019/05/13/using-a-rest-client-to-authenticate-to-elm-clm-applications/ for some insights. 


permanent link
Kalyani Deshmukh (112) | answered Jul 30 '19, 2:06 a.m.

 Hiii,  Could you please provide the code of this problem ?

Thanks in Advance.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.