0

I'm trying to post a json using feign but i get an error from the url that parameters were not sent. This is my code:

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);

Error: feign.FeignException: status 400 reading MyApiClient#postRecurringPayment(String); content: {"errors":{"recurring_application_charge":"Required parameter missing or invalid"}} at feign.FeignException.errorStatus(FeignException.java:62) at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:91) at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:126) at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:74) at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:94) at com.sun.proxy.$Proxy4.postRecurringPayment(Unknown Source) at com.test.TestOauth.testShopifyProducts2(TestOauth.java:49) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.junit.runner.JUnitCore.run(JUnitCore.java:157) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62)

Ron
  • 393
  • 1
  • 4
  • 13

1 Answers1

1

Looking at log http error code 400 mean BadRequest

"errors":{"recurring_application_charge":"Required parameter missing or invalid"

You must pass recurring_application_charge as part of JSON to be accepted by API

But, you need to post complete error log and MyClient class would help advise more.

Umashankar
  • 71
  • 5