Closed edgars closed 6 years ago
Hi @edgars
This is an issue we are currently looking into. Basically, in a scenario like this, the host header is not properly set when forwarding the incoming request to the back-end. For now, as a workaround, you can explicitly set the host header in the code.
@http:resourceConfig {
methods:["GET"],
path:"/cotacao"
}
resource cotacao (http:Request req, http:Response res) {
http:Response clientResponse = {};
req.setHeader("Host", "api.bcb.gov.br"); // explicitly set the host header
clientResponse, err = httpConnector.get("/dados/serie/bcdata.sgs.1/dados/ultimos/1?formato=json", req);
println("GET request: from Dolar Service Banco Central Brasil");
res.forward(clientResponse);
}
Related issue: #3203
Hi @edgars
We have fixed the issue via PR #4166 and it is no longer required to set the host header explicitly.
As per the above comment, I am closing the issue. Thanks for reporting the issue.
Hi People,
I tried to execute the following API url invocation:
http://api.bcb.gov.br/dados/serie/bcdata.sgs.1/dados/ultimos/1?formato=json
I had written the following service:
The return execution returns a 302 HTTP return code, and no response, besides I get an error in the Composer saying: Unexpected error occurred while sending request. Make sure you have entered valid request details.
Any idea of why is it working in the way?