D
D
des1roer2017-07-26 19:15:02
Yii
des1roer, 2017-07-26 19:15:02

Yii2 api how to be?

if you contact by api then

Invalid Parameter - yii\base\InvalidParamException
Response content must not be an array.

and if
'response' => [
        'format' => yii\web\Response::FORMAT_JSON,
        'charset' => 'UTF-8',
    ],

then in index
{"name":"Not Found","message":"Page not found.","code":0,"status":404,"type":"yii\web\NotFoundHttpException"}
rep https ://github.com/des1roer/yii2test
i.e. on the path mysite/api/user I want to see json
but the mysite site itself and other mysite/about pages should work as usual

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Sazanovich, 2017-07-27
@uniqby

Nothing is clear from your question. Try to be more specific.

M
Maxim Timofeev, 2017-07-27
@webinar

You went somewhere, got an error that the server response cannot be an array, and this is true. Can not. Then you configured the response as json and your array became a Json string. Everything is logical. What is the problem? Can you describe what you expect to get?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question