Я пытаюсь сделать запрос API с application / x-www-form-urlencoded.
Вот мой симулированный клиент:
@Bean
public YandexDelivery yandexDelivery() {
return Feign.builder()
.client(new OkHttpClient())
.encoder(new FormEncoder())
.decoder(new GsonDecoder())
.logger(new Slf4jLogger(YandexDelivery.class))
.logLevel(Logger.Level.FULL)
.target(YandexDelivery.class, "https://delivery.yandex.ru/api/last/searchDeliveryList");
}
Вот мой интерфейс:
public interface YandexDelivery {
@RequestLine("POST")
@Headers({"Content-Type: application/x-www-form-urlencoded"})
Delivery getDeliveryVariants(Map<String, ?> request);
}
Вот как я звоню:
@Autowired
private YandexDelivery yandexDelivery;
@Override
public Delivery getDeliverysType(String cityFrom, String cityTo, Integer clientId, String deliveryType, Integer height, Integer indexCity, Integer length, Integer senderId, Integer weight, Integer width) {
DeliveryVariantsModel model = new DeliveryVariantsModel(cityFrom, cityTo, clientId, deliveryType, height, indexCity, length, senderId, weight, width);
HashMap<String, String> map = new HashMap<>();
map.put("secret_key", model.getSecretKey());
map.put("client_id", model.getClientId().toString());
map.put("sender_id", model.getSenderId().toString());
map.put("city_from", model.getCityFrom());
map.put("city_to", model.getCityTo());
map.put("weight", model.getWeight().toString());
map.put("length", model.getLength().toString());
map.put("width", model.getWidth().toString());
map.put("height", model.getHeight().toString());
map.put("delivery_type", model.getDeliveryType());
map.put("index_city", model.getIndexCity().toString());
return yandexDelivery.getDeliveryVariants(map);
}
И вот моя ошибка:
java.lang.ClassNotFoundException: feign.Request$Body