It's all about the answers!

Ask a question

While trying to fetch all components of a project area in GCM, 400 Bad request error


Thiruvenkadam Dhanaraj (27217) | asked Feb 09 '22, 6:58 a.m.

 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


Comments
Ian Barnard commented Feb 09 '22, 12:23 p.m. | edited Feb 09 '22, 12:41 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
FYI 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.

What version and ifix are you using? Have you tried updating to the latest ifix?

How do you get your authentication cookies? Could they have expired between the requests?

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?

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.


David Honey commented Feb 09 '22, 1:03 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Check gc.log for any associated errors.


David Honey commented Feb 09 '22, 1:09 p.m. | edited Feb 09 '22, 1:09 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I hope you are using OSLC discovery to determine that query base URI of an OSLC query capability and not hard coding or constructing the URI https://localhost/gc/oslc-query/components/_FWAMUDJjEey62-ishdsdfsr.That query base URI is for a specific project area. If that project area is archived, that query capability should return an error response.

As Ian suggests, first try using a logged-in browser REST client.

So far, there is insufficient information to answer your question.

Accepted answer


permanent link
David Honey (1.8k17) | answered Feb 11 '22, 10:50 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.

Michael Rowe selected this answer as the correct answer

Comments
Michael Rowe commented Oct 19 '23, 3:50 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR

Closing this question as accepted 

One other answer



permanent link
Thiruvenkadam Dhanaraj (27217) | answered Feb 11 '22, 10:02 a.m.

 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
Ian Barnard commented Feb 11 '22, 11:40 a.m. | edited Feb 11 '22, 11:40 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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.

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.