mardi 23 mars 2021

How to send RequestBody correctly to PUT

In my Controller file (backend) there is a PUT like this:

@PutMapping("/sanction")
fun putSanctionUndo(
        @RequestBody inputDTO: InputDTO
)

What is the correct way of sending the body from the frontend? I'm thinking in something like this:

  export const putSanctionUndo = async ({Id, ValidationId}) => {
      const { data } = await apiClient.put('/sanction', {
        body: {
          "Id": Id,
          "ValidationId": ValidationId,
        },
      });
   return data;
  }

I'm not sure if the "body" is correct. Do I need to declare is as a json or semethng?




Aucun commentaire:

Enregistrer un commentaire