Issue
Below is the code snippet where i need to pass the change_task objects in the query params for the POST request. how can i achieve this without adding it in the body ?
"change_task": [
{
"change_task_type": "Validation",
"planned_start_date": "2022-09-29T20:30:00",
"assignment_group": "CSRT_L2_Support",
"planned_end_date": "2022-09-30T02:30:00",
"short_description": "Test validation",
"description": "test Validation task"
},
{
"change_task_type": "Implementation",
"planned_start_date": "2022-09-29T20:30:00",
"assignment_group": "CSRT_L2_Support",
"planned_end_date": "2022-09-30T02:30:00",
"short_description": "test implementation",
"description": "test implementation task"
}
]
Solution
First of all you may ask why i should pass array of attributes with in query param, instead the content body (request body) is used for the data that is to be uploaded/downloaded to/from the server and the query parameters are used to specify the exact data requested.
So theoretically the request body should contain the data you are posting or patching and the query string, as part of the URL (a URI), it's there to identify which resource you are posting or patching. Regarding to your specification and shared data perhaps its better to use content body instead of query string, this article may help as well.
But if yet you instead to use as query string you must know the answer is depends in framework-specific, see specific answers in here.
Answered By - Lunatic
Answer Checked By - Candace Johnson (JavaFixing Volunteer)