我正在尝试使用 feign 发布一个 json,但我从 url 中收到一个错误,即未发送参数。这是我的代码:
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", "Rabbit SEO");
jsonObject.put("price", "10");
jsonObject.put("test", "true");
jsonObject.put("return_url", "https://www.rabbitseo.com/shopifyPaidGuest");
String content = jsonObject.toString();
System.out.println("content = " + content);
String result = myClient.postRecurringPayment(content);
@RequestLine("POST /admin/recurring_application_charges.json")
@Headers("Content-Type: application/json")
String postRecurringPayment(String content);
return Feign.builder()
.requestInterceptors(requestInterceptors)
.target(MyApiClient.class, myShopifyUrl);
I tried also with the gson decoder and encoder:
return Feign.builder()
.decoder(new GsonDecoder())
.encoder(new GsonEncoder())
.requestInterceptors(requestInterceptors)
.target(MyApiClient.class, myShopifyUrl);
错误:feign.FeignException:读取 MyApiClient#postRecurringPayment(String) 的状态 400;内容: {"errors":{"recurring_application_charge":"必需参数丢失或无效"}} at feign.FeignException.errorStatus(FeignException.java:62) at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:91 ) 在 feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:126) 在 feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:74) 在 feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:94) 在 com.sun.proxy.$ sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 的 sun.reflect.NativeMethodAccessorImpl 的 com.test.TestOauth.testShopifyProducts2(TestOauth.java:49) 的 Proxy4.postRecurringPayment(Unknown Source)。