Eugene S
Eugene S

Reputation: 161

Yii2 RESTful API doesn't accept request in header "Accept: text/plain"

My RESTful API doesn't work If I set "Accept: text/plain" in request header and It returns an Error page with title "unsupported media type". But It works nice If "Accept: application/json" or "Accept: application/xml" is set in request header.

Somebody knows what changes I must do so My API works on accepting request with "Accept: text/plain" in header ?

Thanks in advance

Upvotes: 1

Views: 620

Answers (1)

Beowulfenator
Beowulfenator

Reputation: 2300

Take a look at Content negotiation in the guide.

Essentially, you configure your application's content negotiator to accept text/plain, and then add a formatter for this media type.

Of course, you'll need to implement the formatter class yourself using the ResponseFormatterInterface.

Upvotes: 1

Related Questions