Php GitLab API`400错误请求`response:错误请求
我正在使用GitLab API提交一个mp3文件,它已经工作了很多年没有出现问题,最近几周它抛出了错误Php GitLab API`400错误请求`response:错误请求,php,gitlab-api,Php,Gitlab Api,我正在使用GitLab API提交一个mp3文件,它已经工作了很多年没有出现问题,最近几周它抛出了错误 GuzzleHttp\Exception\ClientException: Client error: `POST https://gitlab.com/api/v4/projects/.../repository/commits/` resulted in a `400 Bad Request` response in file vendor/guzzlehttp/guzzle/src/Ex
GuzzleHttp\Exception\ClientException: Client error: `POST https://gitlab.com/api/v4/projects/.../repository/commits/` resulted in a `400 Bad Request` response in file vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113
这是我正在使用的代码
$client = new Client([
// Base URI is used with relative requests
'base_uri' => 'https://gitlab.com/',
// You can set any number of default request options.
'timeout' => 300,
]);
$files = [
[
'name' => 'branch',
'contents' => 'TEST'
],
[
'name' => 'commit_message',
'contents' => 'Some message'
],
[
'name' => 'actions[][action]',
'contents' => 'update'
],
[
'name' => 'actions[][file_path]',
'contents' => 'gitlab filepath/test.mp3'
],
[
'name' => 'actions[][content]',
'contents' => file_get_contents('localfilepath/test.mp3')
],
];
$response = $client->request('POST', '/api/v4/projects/.../repository/commits/', [
'headers' => [
'PRIVATE-TOKEN' => $TOKEN
],
'multipart' => $files
]);
return $response->getBody()->getContents();
```
Thanks in Advance
他们是否更改了API?对我来说,这听起来像是服务器上的一个问题。我不确定gitlab是否更改了他们的API。但我假设我使用的是GuzzleHttp的某个旧版本,尽管我不记得我更新了composer@miken32,但它还是进行了更新。你能更清楚地说明你提到的可能的服务器问题吗?唯一的问题是我所知道的变化是我办公室互联网公共ip的变化。我们所有的服务器都位于谷歌云中。我将公共ip添加到防火墙规则中。您是否看到与此相关的任何依赖项?如果您没有更改代码,并且服务器以错误响应,那么可以合理地假设服务器上发生了更改。这可能是暂时的问题,也可能是需要调整代码以弥补的问题。