這下面的代碼是調用webservice的,我想實現與Retrofit
在Android,但我得到這個錯誤:實現用於改造自定義標題和我沒有得到任何發現改造註解,錯誤
No Retrofit annotation found
調用Web Service
與CURL
:
curl -H "X-Auth-Token: 9HqLlyZOugoStsXCUfD_0YdwnNnunAJF8V47U3QHXSq" \
-H "X-User-Id: aobEdbYhXfu5hkeqG" \
http://localhost:3000/api/v1/channels.list
我寫這個接口像上面的代碼:
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Header;
public interface RocketRestfulService {
@GET("/api/v1/channels.list")
Call<List<ChannelsList>> getChannelsList(
@Header("X-Auth-Token") String AuthToken,
@Header("X-User-Id") String UserId,
ChannelsList channelsList);
}
,我這段代碼調用此休息Web Service
:
ChannelsList channelsList = new ChannelsList();
Call<List<ChannelsList>> call = rocketRestfulService.getChannelsList(
"HNv1VtMiyUky2RkXWUydyj4f2bfciQ6DzVQgKULSwfe",
"Wz9ex2N2z9zzJWdzD",
channelsList);
call.enqueue(new Callback<List<ChannelsList>>() {
@Override
public void onResponse(Call<List<ChannelsList>> call, final Response<List<ChannelsList>> response) {
Log.e("contentLength ", response.code() + "");
}
@Override
public void onFailure(Call<List<ChannelsList>> call, Throwable t) {
t.printStackTrace();
}
});
什麼我的代碼,我不能打電話,我得到錯誤的問題?
我得到這個錯誤'非身體HTTP方法不能包含@身體現在 –
@ Mahdi.Pishguy我更新了我的答案。 –
我試圖在Android上實現這個鏈接,爲這個Web服務改進'https:// rocket.chat/docs/developer-guides/rest-api/channels/list'和'HTTP Method'是'GET'我在Web瀏覽器上,有些其他客戶端沒有任何問題 –