改造如何在 url 中使用冒号?

Retrofit how to use colon in url?

我正在使用 Google 照片 API 开发一个 Android 应用程序。

我正在尝试使用以下方法将图像文件上传到 Google 照片服务器 API。

https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate

根据文档,我应该使用下面URL来上传图片文件。

POST https://photoslibrary.googleapis.com/v1/mediaItems:batchCreate

所以我使用改造来编写代码。

@Headers("Content-type: application/json")
@POST("mediaItems:batchCreate") // The point is here
fun batchCreate(@Header("Authorization") authorization: String, @Body batchCreateRequest: BatchCreateRequest): Observable<BatchCreateResponse>

当我运行它时,发生了IllegalArgumentException。

java.lang.IllegalArgumentException:格式错误 URL。基础:https://photoslibrary.googleapis.com/v1/,相对:mediaItems:batchCreate

我该怎么做才能解决这个问题?

尝试使用 @POST("./mediaItems:batchCreate") 而不是 @POST("mediaItems:batchCreate")