Yii app request post, wrong content-type (not parsed)

Hi I’m trying to use the HTTP DELETE method passing body params.
But the value of post (Yii::$app->request->post()) is like that :

array(1) {

["----------------------------402107669720104635464403

Content-Disposition:_form-data;_name"]=>

string(224) ""userAltId"

1

----------------------------402107669720104635464403

Content-Disposition: form-data; name="accessToken"

...

----------------------------402107669720104635464403--

"

}

And by printing the $_POST I get an empty array :
array(0) {

}

What I expect is a simple array : [‘userAltId’ => 1, ‘accessToken’ => ‘…’]

Here is what my request looks like in postman :

Would someone know why this format is returned ?
I got other functions where the post values are returned correctly. Is it due to the fact I’m using delete for this request ?

Thanks in advance for your answers.

That’s because you are sending multipart data.
Why not use form-url-encoded?

I always use just JSON data (I think it is raw in Postman, but haven’t used postman in years) and it is quiet simpler with Rest API. Also I use Insomnia instead of postman. IMHO, Postman have become too bloated and complex.

1 Like