54
Views
4
Comments
Solved
REST API 400 bad request on dynamic query parameter from dropdown
Application Type
Reactive

Hi,

Context:
I'm consuming public Jira API with project/application name as query parameter, which then, based on the response updates an entity. This data is displayed on the screen. The project name is concatenated after selecting from dropdown. But I've been getting 400 Bad request. 

I ran the same in postman, and got the correct response (project : JRACLOUD)

To explain the application : In the image belowThe "Project: " on right side is an expression that shows the project selected (only for testing purpose).
Beneath dropdown is the url generated based on project selected (again for testing as I couldn't understand what went wrong in URL as it is 400 Bad Request).
Call API button hits the API based on project selected from dropdown. (don't select "Select" option as I haven't done the validation - since this is just testing the features for official application)

Adding the log :

I'm attaching the OML for reference.


Thanks & Regards,

Aman Devrath


TestFeatures.oml
UserImage.jpg
Saurabh Shivananda Prabhu Chimulkar
Solution

Hi Aman,

You should increase the logging level of the API to inspect the error. The JQL was not formed properly hence the issue. 

Changes to be done:

In jsonDeserializeSA Action, in the GetSearch Call, I/p Parameter value change to : "'Project'+IN+("+ApplicationName+")"

Have attached file for reference too.


Regards,

Saurabh


TestFeatures_Update.oml
2024-04-15 16-08-47
Aman Devrath

Hi Saurabh,

The logging level was already set to Full, I just added the log in my post. I couldn't understand anything from the log. 

Thank you for the help though. 


Thanks & Regards,

Aman Devrath

UserImage.jpg
Saurabh Shivananda Prabhu Chimulkar

Hi Aman,

Probably you were checking the Error Log.

The module in which your API is available, Go to module in Service Center, under the Integrations Tab, Consumed REST section for the concerned API increase the logging level.

Post the changes getting applied, you can go to ServiceCenter > Monitoring > Integrations  to check the logs. For the oml you had provided the attached stack trace was seen based on which i made the changes.

Hope this helps. Will request you to mark the post in which i shared the oml as Solution in case your issue got resolved.

Thanks & Regards,

Saurabh

HTTP Stack Trace.txt
2024-04-15 16-08-47
Aman Devrath

Hi Saurabh, 

Thank you, I've marked it as solution.

Just one doubt, can you please explain why jql didn't form properly ? wasn't project+in+ part of url ?


I used this and it failed: 
/rest/api/2/search?jql='Project'+IN+({ImpactedSystem})


and now this works with double quotes: 
/rest/api/2/search?jql="'Project'+IN+({ImpactedSystem})"

Thanks & Regards,

Aman Devrath

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.