Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

gianmarx's avatar

Axios.put give me The given data was invalid

I send this object:

created_at: "2022-06-08T09:59:40.000000Z"
description: "dddd"
end_downtime: "2022-06-15T12:59:34.000000Z"
id: 6
init_downtime: "2022-06-15T09:59:34.000000Z"
title: "ddddddddddddsasa"
updated_at: "2022-06-08T09:59:40.000000Z"

via an axios.put call

when it arrives in the controller it must respect the request I made as follows:

public function rules()
{
    return  [
        'title' => 'required|string',
        'description' => 'required|string',
        'init_downtime' => 'required|date',
        'end_downtime' => 'required|date|after:init_downtime'
    ];
}

I just get the following 422 error (422 (Unprocessable Content):

{message: "The given data was invalid.",…}
title: ["Il campo title è obbligatorio."]

I don't understand why, give me this error since the data is there, clearly if I put a generic request it enters the controller etc, but I don't understand. It seems that the specified fields arrive empty but they arrive it's strange

0 likes
3 replies
Tray2's avatar

In your controller method dd the request and see what you get, and share that here.

1 like
gianmarx's avatar

i found the error, I sent the object like this:

		         axios.put(`path/${this.obj}`, {'obj': this.obj})

while sending it like this works

		         axios.put(`path/${this.obj}`,  this.obj)

Please or to participate in this conversation.