Closed bodamithun closed 4 years ago
Also how to forward Json data in the body
Thanks for the great explanation.
The body is automatically forwarded, so no problem there.
My guess is that 5002 needs an ASP.NET setting to allow the media type that you are forwarding. What is the media type of ImagePdfRequest
? Json?
Also, can you debug 5001? I wonder if the request is actually getting rejected by 5001? Does the request ever get there?
Thanks @twitchax for responding, the media type is Json. also i tried putting a break point on 5001, but that never got hit.
Also in the startup.cs
I just have this statement in configureservices method. services.AddProxies();
Am I missing any configuration.
Also this is the error i am able to see in the console
System.Net.Http.HttpClient.AspNetCore.Proxy.HttpProxyClient.LogicalHandler: Information: End processing HTTP request after 1304.7942ms - UnsupportedMediaType info: System.Net.Http.HttpClient.AspNetCore.Proxy.HttpProxyClient.LogicalHandler[101] End processing HTTP request after 1304.7942ms - UnsupportedMediaType System.Net.Http.HttpClient.AspNetCore.Proxy.HttpProxyClient.LogicalHandler: Trace: Response Headers: Date: Tue, 03 Mar 2020 23:05:55 GMT Server: Kestrel Content-Type: application/problem+json; charset=utf-8 Content-Length: 158
Let me try writing a test that will cover this scenario and see what I uncover.
Something fishy, for sure.
@twitchax Thank you... did you find anything.
I am thinking that its not able to parse/accept a Json object if you are passing it in the body. But curious to see what you find...
@twitchax
I think I got this to work... I had the endpoint set to [HttpGet], so changing it to HttpPost got it to work. Thanks for looking into it. I will close this issue.
Ohhhhhh, I didn't even notice that, haha.
Yeah, GET
s cannot have a body.
I have implemented a webapi with aspnetcore.proxy 4.0, all I need my api to do is whatever request It gets I need it to forward that to the another api and what ever response I get back, I need to return it. so I created two api's, one with aspnetcore.proxy and other one is normal api. one ask is the forwarding request should include all the headers and also all the body(raw json data).
I am using postman to test the apigateway, in the headers
image
the web api using dotnet core 3.0 has the implementation of aspnetcore.proxy, I have an endpoint as below. this is running on 5002
I created another rest api with endpoint. this is running 5001
Now Locally when i testing this using postman, I am seeing the following error { "type": "https://tools.ietf.org/html/rfc7231#section-6.5.13", "title": "Unsupported Media Type", "status": 415, "traceId": "|8b5e160c-47410df4b69e21ac.1.1d8faa92_" }
also other questioni have is whats the way to forward the body(the json data that I was sent in the orginal request) in my request to 5001.
Thanks