Retrofit 2.0 – URL concept

by Philip Barlow / from beautifuldecay.com

I struggled  with the new URL way when I started to use this new version. But it’s easy to understand (after miss much because of the old version vices)! Just keep in mind that the base URL and specific URL of a resource are concatenated. So, you must to take care with ‘/’ at the begining and end of URLs. Let’s define a simple rule to avoid mistakes:

The base API URL set in retrofit instance MUST ALWAYS end with ‘/’

new Retrofit.Builder().baseUrl("http://api.themoviedb.org/3/")

The specific URL of a resource must never be initiated with ‘/’


public interface APIService {
@GET("item/")
Call listItens();
}

view raw

APIService.java

hosted with ❤ by GitHub

Deixe um comentário

Preencha os seus dados abaixo ou clique em um ícone para log in:

Logo do WordPress.com

Você está comentando utilizando sua conta WordPress.com. Sair /  Alterar )

Imagem do Twitter

Você está comentando utilizando sua conta Twitter. Sair /  Alterar )

Foto do Facebook

Você está comentando utilizando sua conta Facebook. Sair /  Alterar )

Conectando a %s