How to receive data from a Rest API using Apache Camel

0

And how do I get the data from a REST server passing a basic authorization in the header?

I have tried in many ways and it does not work, and when I test in postman , it works normally.

  • I have tried the simple way:

    from(URL_API_FBITS + "categorias?hierarquia=false")
      .setHeader("Authorization", simple("Basic" + TOKEN))
      .log("${body}").to("file:saida?noop=true");
    
  • Converting to JSON:

    from(URL_API_FBITS + "categorias?hierarquia=false")
      .marshal().json(JsonLibrary.Jackson)
      .setHeader(CONTENT_TYPE, simple(APPLICATION_JSON))
      .setHeader("Authorization", simple("Basic " + TOKEN))
      .log("${body}").to("file:saida?noop=true");
    
  • And it still did not work out.

        
    asked by anonymous 05.12.2017 / 12:57

    1 answer

    0

    I was doing it incorrectly, now I'm using the .to function to perform the request, I changed it to:

    from("timer://foo?fixedRate=true&delay=0&period=10000").setHeader(CONTENT_TYPE, simple(APPLICATION_JSON))
                .setHeader("Authorization", simple("Basic " + TOKEN)).to(URL_API_FBITS + "categorias?hierarquia=false")
                .log("${body}").to("file:saida?noop=true");
    
        
    05.12.2017 / 14:48