I am using ocelot gateway.
Here is the example configuration
{
"DownstreamPathTemplate": "/ipgeo?apiKey={key}&ip={ip}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "api.ipgeolocation.io",
"Port": 80
}
],
"UpstreamHttpMethod": ["GET"],
"UpstreamPathTemplate": "/GLI/secondary?apiKey={key}&ip={ip}"
}
As you can see, there are two query params. When I send a request using postman:
http://localhost:5000/GLI/secondary?apiKey=aaa&ip=8.8.8.8
OCELOT get duplicate query params and generate a downstream url like this:
http://api.ipgeolocation.io/ipgeo?apiKey=aaa&ip=8.8.8.8&apiKey=aaa&ip=8.8.8.8
Console screen:
info: Ocelot.Requester.Middleware.HttpRequesterMiddleware[0]
requestId: 0HMFNFVDSDQH9:0000000A, previousRequestId: no previous request id, message: 301 (Moved Permanently) status code, request uri: http://api.ipgeolocation.io/ipgeo?apiKey=aaa&ip=8.8.8.8&apiKey=aaa&ip=8.8.8.8
How can I change this?
2
Answers
You can use
OR
Same problem,
For me works use this syntax, basically I have removed the "?" symbol in the
UpstreamPathTemplate
: