Ocelot网关Get请求正常但Post请求返回400错误求助
Ocelot网关Post请求返回400 Bad Request问题
我用Ocelot做API网关时碰到个问题:Get请求能正常通过网关转发并拿到响应,但Post请求一直返回400 Bad Request。不过相同的Post请求直接在Postman里调用目标接口,却能成功返回200状态码。我确认Swagger和Postman调用的是同一个网关URL,所以初步排除了Ocelot配置文件的问题。
以下是我的Ocelot.json配置内容:
{ "Routes": [ { "DownstreamPathTemplate": "/api/{everything}", "DownstreamScheme": "https", "DownstreamHostAndPorts": [ { "Host": "localhost", "Port": 44340 } ], "UpstreamPathTemplate": "/gateway/v1/starter/{everything}", "UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ], "SwaggerKey": "starter" }, { "DownstreamPathTemplate": "/api/{everything}", "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { "Host": "localhost", "Port": 21021 } ], "UpstreamPathTemplate": "/gateway/v1/abpstarter/{everything}", "UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ], "SwaggerKey": "abpstarter" } ], "SwaggerEndPoints": [ { "Key": "starter", "Config": [ { "Name": "starter API", "Version": "v1", "Url": "https://localhost:44340/swagger/v1/swagger.json" } ] }, { "Key": "abpstarter", "Config": [ { "Name": "abpstarter API", "Version": "v1", "Url": "http://localhost:21021/swagger/v1/swagger.json" } ] } ], "GlobalConfiguration": { "BaseUrl": "http://localhost:3000", "RequestIdKey": "OcRequestId" } }
内容的提问来源于stack exchange,提问作者Waleed Khaled
相关产品推荐
相关产品推荐

