OBX
OBX

Reputation: 6114

How to define API endpoint for retrofit?

This is my sample URL to the API end point:

https://api.projectoxford.ai/luis/v1/application?id=b0d5b503-eb2e-460a-b028-a3223aa93227&subscription-key=bc1cb297a94f4c9a9b58bcd36280466c&q=start%20test

Now, how do I create the base URL and define end point for use in Retrofit.

I've created model class for JSON, and this is how I defined base URL:

    public class ApiClient {

    public static final String BASE_URL = "https://api.projectoxford.ai/luis/v1/";
    private static Retrofit retrofit = null;


    public static Retrofit getClient() {
        if (retrofit==null) {
            retrofit = new Retrofit.Builder()
                    .baseUrl(BASE_URL)
                    .addConverterFactory(GsonConverterFactory.create())
                    .build();
        }
        return retrofit;
    }
}

This is how I tried to define the end point:

    public interface ApiInterface {
    @GET("application")
    Call<LuisPojo> getValues(@Query("id") String apiKey);


}

But how to add the remaining part, subscription-key and the search term in the end

start test

Upvotes: 1

Views: 1275

Answers (1)

Ravi
Ravi

Reputation: 35549

Append it in your getValues()

@GET("application")
Call<LuisPojo> getValues(@Query("id") String apiKey, @Query("subscription-key") String key, @Query("q") String q);

Upvotes: 2

Related Questions