I am trying to learn retrofit2 by showing my project's GitLab name into recyclerView . but I can not find what is exactly what to do!!! according gitlab wiki I found private-tokens and list of projrct.
this is my baseUrl and I create a builder:
Retrofit.Builder builder = new Retrofit.Builder()
.baseUrl("https://gitlab.com/api/v4/projects?private_token=xxxxxx")
.addConverterFactory(GsonConverterFactory.create());
and this is my endpoint:
@GET("/users/:{userid}/projects")
Call<List<GitLabRepo>> reposForUser(@Path("userid") int user);
my GitLabRepo pojo class:
class GitLabRepo {
private String name;
public String getName() {
return name;
}
}
after running I got this error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sayres.createandroidclient/com.example.sayres.createandroidclient.MainActivity}: java.lang.IllegalArgumentException: baseUrl must end in /: https://gitlab.com/api/v4/projects?private_token=rjezfrSUTn3fcugxLujm/
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.IllegalArgumentException: baseUrl must end in /: https://gitlab.com/api/v4/projects?private_token=xxxxxx/
at retrofit2.Retrofit$Builder.baseUrl(Retrofit.java:513)
at retrofit2.Retrofit$Builder.baseUrl(Retrofit.java:456)
at com.example.sayres.createandroidclient.MainActivity.onCreate(MainActivity.java:34)
at android.app.Activity.performCreate(Activity.java:6679)
I know my problem is related to baseUrl but what is correct gitLab BaseUrl
?
I want just show my project name into list at recycelerview list.
******************Edit****************** I use of poster :
https://gitlab.com/api/v4/projects?private_token=******/users/:******/projects
And I got :
{
"message": "401 Unauthorized"
}
I see into Status codes
at gitlab wiki and wrote there:
401 Unauthorized The user is not authenticated, a valid user token is necessary.
but I have added Private Tokens .