The API method that I call:
public function actionCreate() { $request = Yii::$app->request; $resource = $request->post('resource'); $sourceId = $request->post('sid'); if ($resource && $sourceId) { // Код } else { // Получаю это сообщение throw new HttpException(400, "Check parameters 'resource' (value: $resource) or 'sid' (value: $sourceId)"); } } And the code on Angular that I am trying to call:
var post = function(method, data) { var requestParams = { url: 'api/method', method: 'POST', data: { 'resource': 'asdasd', 'sid': 123 }, headers: { 'Content-Type': 'application/javascript; charset=UTF-8' //'Content-Type': 'application/json; charset=UTF-8' } }; return $http(requestParams); }; var useSource = function(source) { post('sources', { 'resource': source.resourceId, 'sid': source.id }).then(function(response) { console.log('success'); console.log(response); }, function error(response) { console.log('error'); console.log(response); }); } I always get this error:
Check parameters 'resource' (value:) or 'sid' (value:)
As if, I do not specify the parameters when querying in the angular.
What could be the problem?