我正在使用 browserstack screenshots API - https://www.browserstack.com/screenshots/api以下 curl 正在工作:
curl -u "username:password" -H "Content-Type: application/json" -H "Accept: application/json" -d '{"browsers": [{"os": "Windows", "os_version": "7", "browser_version": "8.0", "browser": "ie"}], "url": "http://google.com"}' http://www.browserstack.com/screenshots
但是,当我尝试使用 guzzle 进行相同的调用时,我得到 422 Unprocessable Entity 错误。
$client = new GuzzleHttp\Client();
$request = $client->post('http://www.browserstack.com/screenshots', [
'headers' => ['Content-type' => 'application/json'],
'auth' => ['username', 'password']
]
);
$data = ['browsers' => ['os' => 'Windows', 'os_version' => '7', 'browser_version' => '8.0', 'browser' => 'ie'], 'url' => 'http://google.com'];
$request->setBody($data);
$response = $request->send();
dd($response);
你能建议如何调试这个问题吗?