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.
Мой код
@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);
А так выглядит функция запроса.
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);
}
}
В запросе всё, что идёт после ? - параметры запроса в виде key=value.
Т.е. всё, что после ? не является частью пути и использовать @Path нельзя, надо использовать @Query.
В вашем случае надо как-то так:
@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);
И передавать в переменную portalNamePath что-то типа "portals/" + portalNamePath + "/contact_us"
Продвижение своими сайтами как стратегия роста и независимости