0
votes

I using Resteasy to call my back

So I use a interface to configure my call

@Path("/api/private/configuracao")
public interface ConfiguracaoClient {
    @GET
    @Path("/")
    @Consumes("application/json")
    @HeaderParam(value = "db_teste")
    public ConfiguracaoVO findConfiguracao();
}

and call like this:

public class ConfiguracaoClientImpl {
    ResteasyClient client;
    ConfiguracaoClient configuracaoClient;
    public ConfiguracaoClientImpl() {
        client = new ResteasyClientBuilder().build();
        ResteasyWebTarget target = client.target("http://localhost:8181/");
        target.request().header("public","db_teste");
        configuracaoClient = target.proxy(ConfiguracaoClient.class);

    }

    public ConfiguracaoVO findConfiguracao(){
        return configuracaoClient.findConfiguracao();
    }
}

how can I add a parameter in header? tks

1

1 Answers

1
votes

db_teste should be query param not header param. The right syntax is the following:

@Path("/api/private/configuracao")
public interface ConfiguracaoClient {
    @GET
    @Path("/")
    @Consumes("application/json")
    public ConfiguracaoVO findConfiguracao(@QueryParam("db_teste") String dbTest);
}

Remove this line from ConfiguracaoClientImpl:

target.request().header("public","db_teste");

And you can add the value of db_teste in configuracaoClient.findConfiguracao(value) call.