While trying to fetch all components of a project area in GCM, 400 Bad request error
Hi,
We were trying to fetch all components of a GCM projetc area using Rest API,
This above query fetches all components perfectly fine but later after 10 or 15 mins same server call is requested then we get 400 Bad request error.
We are using cookies to authenticate. We have an application created in low code platform which integrates GCM project area data.
Please let us know how to fix this issue.
Thanks & Regards,
Thiru
Accepted answer
Since this works using RESTclient and Postman, this suggests this is not a GCM server issue, but an error with your Java client code, perhaps relating to authentication. I can't help you further with that.
One other answer
Hi,
We have tried in Rest Client and it works fine.
Please find the answers for the questions asked by Ian,
you're using the OSLC Query capability for components offered by GCM - there's one to query within a project and another to query components across the application, this particular query is within a project.
---- Yes, We need to query for a project. Find all components of a project area.
What version and ifix are you using? Have you tried updating to the latest ifix?
----- We are using ALM 7.0.2 ifix008
How do you get your authentication cookies? Could they have expired between the requests?
------ From the last request made we try to fetch cookie and store it local variable.
------ No. it does not expires between the requests. Request is made after few minutes.
Have you confirmed by checking the messages sent (i.e. not by assuming that they're correct) that the URL/headers/cookies on the failing request are the same as the succeeding request?
------- Yes. Keeping the latest success request and after few minutes again another request is made. it fails with 400 response error. (Bad request)
Have you made the identical request (URL, headers) using a logged-in browser REST client, twice, 10 minutes apart - does it work there? If so you're doing something wrong in your code probably to do with headers/cookies.
------- In Rest Client and Postman is working fine, but in both we don't need to send any cookie to authenticate the API, But in our integrated application we need to send because they use cookies as an authentication.
Comments
Your answer to my 'have you confirmed' question is rather vague - it sounds like you haven't actually checked the URL and the headers and the cookies of the failed request are actually identical to the successful request. Mistaken assumptions are often just wrong guesses. Check them!
Just checked here and when I do a GCM query the response sends a set-cookie for JAZZ_AUTH_TOKEN - does your code handle updating cookies with every request/response? It should. This is also key to keeping logged in, because if your code tries to do an explicit log in only on some assumed auth timeout period then it's bound to fail in the end. Much better to authenticate on demand by examining _all_ responses (even 200) and check if auth needed then do it.
As David says, the problem is entirely in your code because the REST client test shows that there's no problem in the GCM application.
Comments
Ian Barnard
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Feb 09 '22, 12:41 p.m.David Honey
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Feb 09 '22, 1:03 p.m.Check gc.log for any associated errors.
David Honey
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Feb 09 '22, 1:09 p.m.So far, there is insufficient information to answer your question.