0

I am using Feign with Spring and I want to call a rest client that does not respect any standard.

https://uglyservices.com/api/service1/{param1}?token={param2}&&data={jsonData}

I tried with the spring GetMapping but I could not. I've also tried using Feign annotations, for that, create this main class

@SpringBootApplication
@EnableAutoConfiguration
@EnableScheduling
@EnableFeignClients
public class MyApplication {

    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
    }

    @Bean
    public Contract useFeignAnnotations() {
        return new Contract.Default();
    }


}

and I have declared the service as follows

@FeignClient(name = "uglyservices-service",
        url = "${propiedades.uglyservicesURL}")
public interface SimpleServices {

    @RequestLine("GET /service1/{param1}?token={param2}&data={jsonData}")
    public String crearCaso(@Param("param1") String param1, @Param(value = "param2", expander = PrefixExpander.class) String param2, @Param("jsonData") String jsonData);

    static final class PrefixExpander implements Param.Expander {

        @Override
        public String expand(Object value) {
            return value + "&";
        }
    }


}

But I can not get the url to be formed correctly.

I appreciate any advice. Sorry for my English.

user60108
  • 3,270
  • 2
  • 27
  • 43
  • What is non-standard about it? You have 1 path variable and 2 request parameters... There is nothing non-standard about that. The key here is, I guess, 1 is a **path parameter** and you have 2 **request parameters** which are different things and belong in different annotations. – M. Deinum Apr 16 '18 at 17:30
  • The non-standard is && betwen parameters – user60108 Apr 16 '18 at 17:46
  • Just declare it in the URL and it should work. You now only have a single one so obviously that doesn't match. I also wonder what you had with regular Spring annotations. – M. Deinum Apr 16 '18 at 17:47
  • If I put two &, I can not get to the service. With Spring GetMapping I could not do it either – user60108 Apr 16 '18 at 17:55

0 Answers0