2017-04-25 2 views
2

Ich verwende Yii2 REST mit ActiveController eine neue Pessoa() zu erstellen, auf Apache funktioniert gut, aber auf IIS 8 ein Fehler auftritt.Yii2 REST API IIS Objekt bewegt

Kennt jemand eine Konfiguration in IIS?

REQUEST

Request URL:http://10.192.1.145/api/pessoa 
Request Method:POST 
Status Code:201 Created 
Remote Address:10.192.1.145 
Referrer Policy:no-referrer-when-downgrade 

RESPONSE

<head><title>Document Moved</title></head> 
<body><h1>Object Moved</h1>This document may be found 
<a HREF="http://10.192.1.145/api/pessoa/45">here</a></body>{"id":"21"} 

Antwort

1

ich diese ein ähnliches Problem hatte. Es scheint mit FastCGI verwandt zu sein. Ich bin mir nicht sicher. Ich weiß, dass es passiert, wenn Antwort-Header auf 201 http-Statuscode (this line in source code) gesetzt werden, die später von IIS geändert werden. Wenn Sie Zugriff auf Server versuchen, diese Lösungen:

W7 Pro IIS 7.5 overwrites PHP Location: Header (solved)

In meinem Fall hatte ich nur FTP-Zugriff auf Server, so dass ich die Aktion erstellen, indem so etwas wie außer Kraft gesetzt, was folgt einen Statuscode 200 zu zwingen, anstelle von 201:

public function actions() 
{ 
    $actions = parent::actions(); 
    unset($actions['create']); 
    return $actions; 
} 

public function actionCreate() { 
    $model = new Pessoa(); 
    $model->load(Yii::$app->getRequest()->getBodyParams(), ''); 
    if ($model->save() === false && !$model->hasErrors()) { 
     throw new ServerErrorHttpException('Failed to update the object for unknown reason.'); 
    } 
    return $model; 
}