我想将信息发布到外部 api,但我一直收到错误 422。获取信息和授权工作正常。我正在使用 Symfony Http 客户端,授权和标头现在在 framework.yaml 中定义。
Api 文档片段:
curl "https://business.untappd.com/api/v1/locations/3/custom_menus"
-X POST
-H "授权:基本 bmlja0BuZXh0Z2xhc3MuY286OW5kTWZESEJGcWJKeTJXdDlCeC0="
-H "Content-Type: application/json"
-d '{ " custom_menu": { "name": "葡萄酒选择" } }'
我的服务片段:
public function customMenu(): int
{
$response = $this->client->request(
'POST',
'https://business.untappd.com/api/v1/locations/'.$this->getLocationId().'/custom_menus',
[
'json' => [
['custom_menu' => ['name' => 'Wine selection']],
],
]
);