FATAL EXCEPTION: main Process: com.riyadbankacademy.general_portals, PID: 26644 java.lang.IllegalArgumentException: URL query string "type=portals/{portalNamePath}/contact_us&content[submit]=submit" must not have replace block. For dynamic query parameters use @Query. 

My code

 @POST("v2/message/email?type=portals/{portalNamePath}/contact_us&content[submit]=submit") Call<SendMailStatus> sendMail(@Query("content[name]") String name, @Path("portalNamePath") String portalNamePath, @Query("content[portal]") String portalNameContent, @Query("content[email]") String email, @Query("content[subject]") String subject, @Query("content[message]") String message); 

And this is what the query function looks like.

 public static void sendMail(Context context, String name, String email, String subject, String message,String portalNamePath,String portalNameContent) { KnowledgeCityApi knowledgeCityApi = ApiMethods.createKnowledgeCityApi(); if (knowledgeCityApi != null) { Call call = knowledgeCityApi.sendMail(name, portalNamePath, portalNameContent, email, subject, message); Log.d(TAG, "sendMail: " + call.request().toString()); ApiMethods.makeRequest(call, Messages.RESPONSE_SEND_MAIL); } } 
  • Try to write more meaningful headlines - a good headline of 57% increases the likelihood of getting an answer to the question - YuriySPb

1 answer 1

In the request, all that comes after ? - query parameters in the form key=value .

Those. whatever after ? is not part of the path and you cannot use @Path , you must use @Query .

In your case, you need something like this:

 @POST("v2/message/email?content[submit]=submit") Call<SendMailStatus> sendMail(@Query("content[name]") String name, @Query("type") String portalNamePath, @Query("content[portal]") String portalNameContent, @Query("content[email]") String email, @Query("content[subject]") String subject, @Query("content[message]") String message); 

And pass to the portalNamePath variable something like "portals/" + portalNamePath + "/contact_us"

  • Thank. Now it’s clear what the problem was - user239760