Always Getting an HTML in Response from RTC
It seems like the RTC server doesn't like my url request. After the /ccm/ part, I can essentially write whatever I want and get the same result. So I'm guessing something about what I've got is wrong. Following the answer from my previous [post][1], I'm pretty sure I have the right link from the "services" file in the <oslc_cm:simpleQuery><dc:title>Change request queries</dc:title> tag. So I'm not sure if there's something else it doesn't like? It no longer fails authentication and I'm now using form-based rather than basic, so I don't think it's authentication-related. Any ideas?
Accepted answer
I can't say enough about Postman to figure this all out. Thanks, @Ralph Schoon for that tip! Apart from that, my issues were many. The HTML was definitely indicating a problem with authentication.
This is what I've come to understand.
The comment "// * Still says AuthRequired here for some reason *" is telling of the fact that authorization is indeed not occurring. The header value for "X-com-ibm-team-repository-web-auth-msg" will indeed be null when it is officially no longer required.
It is failing because:
- The _formPost itself needs basic authentication to post the form values
- The CookieContainer is null. Creating a new CookieContainer allows for the authentication to proceed.
- The "authenticated/j_security_check" is not correct. It should simply be "j_security_check".
- When requesting the data a second time after authenticating, a new request must be created and using the CookieContainer from the original.
Comments
One other answer
- Use GET not POST
- Use Postman until you understand what you are doing See https://rsjazz.wordpress.com/2019/05/13/using-a-rest-client-to-authenticate-to-elm-clm-applications/
-
JSON is not necessarily supported for everything.
Comments
Thanks Ralph. Postman seems interesting as a learning tool, but I'm not seeing "Form Auth" as an authentication method. Also, switching from POST to GET gives an error because I'm "posting" my credentials and not trying to "get" from them. Adding the method = GET to the request itself also doesn't change anything--I still get the strange HTML response.
I've managed to get Postman to work with my commands. I'm not yet sure why I can't duplicate it in code. I think it's doing something in the background with cookies that I'm not doing in the code. My POST for authentication is finally not having an auth header at all which is what I expect to pass. But when I request a GET with the request object whose CookieContainer I think I'm using, it again returns authrequired. So it's not carrying over from the formPost to the request. Any idea why?