How to receive data from a Rest API using Apache Camel

Asked

Viewed 182 times

0

And how do I receive data from a server REST passing an authorisation of the type basic in the header?

I’ve tried so many ways and it doesn’t work, and when I test Postman, works normally.

  1. I’ve tried it simple:

    from(URL_API_FBITS + "categorias?hierarquia=false")
      .setHeader("Authorization", simple("Basic" + TOKEN))
      .log("${body}").to("file:saida?noop=true");
    
  2. 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 didn’t work out.

1 answer

0


I was doing it incorrectly, now I’m using the . to function to perform the request, I changed 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");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.