2016-02-15 4 views
0

Je dois appeler un api utilisant retrofit 2 dans android. mais sans valeurs. Quand je fais cela, cela montre qu'il doit y avoir au moins 1 @field. Voici le code que j'utilise.Comment envoyer un appel post-retrofit 2 sans paramètres

public interface gitAPI { 
    @FormUrlEncoded 
    @POST("/MembersWS.svc/GetMemberAvailability/MBR0011581") 
    Call<Questions[]> loadQuestions(); 
} 






Retrofit retrofit = new Retrofit.Builder() 
       .baseUrl("http://192.168.1.99:82") 
       .addConverterFactory(GsonConverterFactory.create()) 
       .build(); 
    // prepare call in Retrofit 2.0 
    gitAPI stackOverflowAPI = retrofit.create(gitAPI.class); 

    Call<Questions[]> call = stackOverflowAPI.loadQuestions(); 
    call.execute(); 
+0

essayer d'enlever l'annotation @FormUrlEncoded –

Répondre

1

Declare valeur corporelle dans votre interface avec suivante:

@Body RequestBody body et enveloppez chaîne objet JSON:

RequestBody body = RequestBody.create(MediaType.parse("application/json"), (new JsonObject()).toString());