0

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"
    }
  ]
  • Why don't you want to add it in the body? Technically you could do some special encoding to put it in the query string, but a query string is limited in length and can lead to security issues as well. – GeertPt Sep 23 '22 at 07:53

1 Answers1

0

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.

Lunatic
  • 1,519
  • 8
  • 24