1
votes

I'm trying to call the youtube API which looks like this:

https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=10&playlistId=UU4MePVEgmibN-KAMF4-heTA&key=<KEY>

But I'm getting the error "URL query string" part = snippet {maxResults} {playlistId} {key} "must not have replace block.For dynamic query parameters use @Query." Am I doing something wrong ?? I'm currently doing so:

@GET("playlistItems?part=snippet{maxResults}{playlistId}{key}")
Call<PlaylistItemListResponse> getPlayListItemsList(@Query("maxResults") int maxresults, @Query("playlistId") String playlistId, @Query("key") String key);
1

1 Answers

0
votes

You need to fix the URL in the @GET Annotation.

Please check the Retrofit Documentation at: https://square.github.io/retrofit/2.x/retrofit/index.html?retrofit2/http/Query.html

Simple Example:

@GET("/friends") Call friends(@Query("page") int page);

Calling with foo.friends(1) yields /friends?page=1.

Probably better for your case is using a Query Map.