1
resposta

apache camel método post

Bom dia, galera!

Como faço para chamar um método post que pode passar paramtros no body e na url com apache camel?

Atenciosamente.

Fernando Hiar.

1 resposta

Exemplo:

from("direct:addstar")

    // Set up some variables for our HTTP request - we'll use these later!
    .setHeader("repoOwner", constant("apache"))
    .setHeader("repoName", constant("camel"))

    // Set the body to null, because it is required by the GitHub API.
    .setBody(simple("${null}"))

    // Now invoke the GitHub API with the null Body
    // PUT /user/starred/:owner/:repo
    .toD("https://api.github.com/user/starred/${header.repoOwner}/${header.repoName}" +
            "?httpMethod=PUT" +
            "&authMethod=Basic" +
            "&authUsername=XXX" +
            "&authPassword=XXX" +
            "&authenticationPreemptive=true")

    .log("Response code from the operation was: ${header.CamelHttpResponseCode}");

Dá para usar variações dependendo do que você precisa: https://camel.apache.org/components/latest/http-component.html