Repository: GitLabPHP/Client (php)

Issue:
Cannot upload project avatar: 'avatar is invalid'
[Our project calls `uploadAvatar()`](https://github.com/acquia/cli/blob/fae9193756f42a2b873b573327a6747067e96b66/src/Command/CodeStudio/CodeStudioCommandTrait.php#L253) after creating a GitLab project. I'm pretty sure this has worked in the past, but recently stopped working, throwing an `avatar is invalid` exception: https://github.com/acquia/cli/issues/1377

I did some debugging and it looks like a problem with this library. A curl request with the same avatar to the same API endpoint works fine:

`curl --location --request PUT 'https://code.acquia.com/api/v4/projects/1092' --header 'Authorization: Bearer [snip]' --form 'avatar=@drupal_icon.png'`

I suspect GitLab changed something in the expected file or PUT format that's breaking this call.

Pull request description:
[11.9] Correct upload avatar endpoint
Closes #739, #745.

Patch:
diff --git a/src/Api/Projects.php b/src/Api/Projects.php
index 1ca253c..43773b1 100644
--- a/src/Api/Projects.php
+++ b/src/Api/Projects.php
@@ -1207,7 +1207,7 @@ class Projects extends AbstractApi
      */
     public function uploadAvatar($project_id, string $file)
     {
-        return $this->put($this->getProjectPath($project_id, ''), [], [], ['avatar' => $file]);
+        return $this->put('projects/'.self::encodePath($project_id), [], [], ['avatar' => $file]);
     }
 
     /**


Test patch:
diff --git a/tests/Api/ProjectsTest.php b/tests/Api/ProjectsTest.php
index bc7e64e..6def3b0 100644
--- a/tests/Api/ProjectsTest.php
+++ b/tests/Api/ProjectsTest.php
@@ -2780,7 +2780,7 @@ class ProjectsTest extends TestCase
         $api = $this->getApiMock();
         $api->expects($this->once())
             ->method('put')
-            ->with('projects/1/', [], [], ['avatar' => $fileName])
+            ->with('projects/1', [], [], ['avatar' => $fileName])
             ->will($this->returnValue($expectedArray));
         $this->assertEquals($expectedArray, $api->uploadAvatar(1, $fileName));
         \unlink($fileName);