-
Hello I am sorry I am writing right here, I just can't find much of community resources for Ocelot save from some stackoverflow So here's question My target API backend methods expects parameters to be passed in body as content-type of So, basically I need to transform my GET request to my gateway endpoint
and I just can't figure out is it even possible with Ocelot right now? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I've had to do the same thing recently to take a GET request with parameters and assemble some json to be POSTed to the back-end service, This should get you off in the right direction... public class ConvertGetToPostHandler : DelegatingHandler
{
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
//do stuff to get/validate your querystring parameters, e.g.
var yourFormData = request.RequestUri.Query.TrimStart('?');
request.Content = new StringContent(yourFormData, Encoding.UTF8, "application/x-www-form-urlencoded");
request.Method = HttpMethod.Post;
return await base.SendAsync(request, cancellationToken);
}
} Of course, I'd be happy to get another opinion... |
Beta Was this translation helpful? Give feedback.
I've had to do the same thing recently to take a GET request with parameters and assemble some json to be POSTed to the back-end service,
I ended up using the DelegatingHandler.
This should get you off in the right direction...