Php Laravel-狂饮呼叫柱返回获取

Php Laravel-狂饮呼叫柱返回获取,php,laravel,guzzle,Php,Laravel,Guzzle,我试图在Guzzle中发出POST请求,但是我调用的API返回一个响应,就好像我发出了GET请求一样 控制器 类控制器扩展BaseController { 常量URL=http://apidomain.com'; 公共函数构造() { $this->client=new\GuzzleHttp\client(); } 公共函数createItem() { $body=[ 'itemId'=>123, ]; $this->callPostRequest('api/items',$body); } 私

我试图在Guzzle中发出POST请求,但是我调用的API返回一个响应,就好像我发出了GET请求一样

控制器

类控制器扩展BaseController
{
常量URL=http://apidomain.com';
公共函数构造()
{
$this->client=new\GuzzleHttp\client();
}
公共函数createItem()
{
$body=[
'itemId'=>123,
];
$this->callPostRequest('api/items',$body);
}
私有函数callPostRequest($endpoint,$body)
{
$response=$this->client->post(self::URL.$endpoint[
“标题”=>[
'内容类型'=>'应用程序/json',
'授权'=>“承载{$this->getAccessToken()}”,
],
“form_params”=>body$
]);
dd(\GuzzleHttp\json_decode((字符串)$response->getBody());
}
}
提供商

类ApiServiceProvider扩展了BaseServiceProvider
{
公共函数boot()
{
$this->loadViewsFrom(_DIR__.'/../Views,'api');
父::boot();
}
公共功能路线()
{
$group=[
'前缀'=>'/api',
“名称空间”=>“Api\Controllers”,
];
路由::组($组,函数(){
路由::获取('/create item','Controller@createItem')
->名称('api::create item');
});
}
}

post端点应该允许我添加一个项目;但是,它不是添加,只是返回当前保留的项目列表。

请发布您的路线好吗?以及您发布的函数所属的控制器。抱歉,函数位于类controller extends BaseController中。路线在ApiServiceProvider Extendes BaseServiceProvider类中是的,发布代码以便我们可以提供帮助:D:D如果我们看不到代码,我们将无法提供帮助。抱歉,我已更新了上面的帖子