-2

I've been following an online tutorial and carefully following the code below as an API interface. I keep getting errors like illegal start of type and such:

package com.gwiddle.airsoftcreations.airsoftapp;

import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;

public interface ApiInterface {

    @GET("register.php")
    Call<User> performRegistration(@Query("name") String Name, 
        @Query("user_name") String UserName, @Query("user_password") String UserPassword );

    @GET("login.php")
    Call<User>perfromUserLogin@Query("user_name") String Username, 
        @Query("user_password") String UserPassword)
}

Please assist

InsaneCat
  • 2,115
  • 5
  • 21
  • 40
  • probably you should not name your variable with capital letter. So try to rename it to String userPassword, String username, etc. Because in java capital letters used for class names, so maybe some of your classes has name Username for example. – Stanislav Parkhomenko Sep 04 '18 at 16:20
  • Follow this to ask a question for others to understand your problem too: https://stackoverflow.com/help/how-to-ask – Sudhanshu Vohra Sep 05 '18 at 03:03
  • Can you link to the tutorials? Do they also contain typos? – OneCricketeer Sep 05 '18 at 03:12

2 Answers2

0

try changing this

@GET("login.php")
Call<User>perfromUserLogin@Query("user_name") String Username, 
    @Query("user_password") String UserPassword)

to this

@GET("login.php")
Call<User> perfromUserLogin(@Query("user_name") String Username, 
    @Query("user_password") String UserPassword);
Shadow Suave
  • 114
  • 1
  • 10
0

As correctly pointed out by @Shadow Suave there is an error in the call you have written for login that you have written. It's currently:

@GET("login.php")
    Call<User>perfromUserLogin@Query("user_name") String Username, 
        @Query("user_password") String UserPassword)

You have to change that call to:

 @GET("login.php")
        Call<User> perfromUserLogin(@Query("user_name") String Username, 
            @Query("user_password") String UserPassword);

Also I feel that these methods are supposed to register and login the user to the specified service so they should be POST methods because GET request methods doesn't make any sense here, so you should check that too. Also although you are following a tutorial right now but for future purpose you should know that you should never pass in your username and specially password as query parameter. Because query parameters can shown in the web server logs or history, for more info see this.

Sudhanshu Vohra
  • 1,345
  • 2
  • 14
  • 21