WireMock.Net: ProxyAndRecord does not save query-parameters, headers and body

When we try to record a request with HttpMethod as post, then we are getting error as below. Can someone please help me if I am missing anything.

I am starting server as below

string url = "http://localhost:1111/";
            var server = FluentMockServer.Start(new FluentMockServerSettings
            {
                Urls = new[] { url },
                StartAdminInterface = true,
                ReadStaticMappings=true,
                ProxyAndRecordSettings = new ProxyAndRecordSettings
                {
                    Url = "http://www.google.com/",
                    SaveMapping = true
                }
            });

Error is as below. But when I create a static mapping for the above serevr with Post as method then it works fine. Seeing the below issue only when we try to record it.

System.InvalidOperationException: Misused header name. Make sure request headers are used with HttpRequestMessage, response headers with HttpResponseMessage, and content headers with HttpContent objects.
   at System.Net.Http.Headers.HttpHeaders.CheckHeaderName(String name)
   at System.Net.Http.Headers.HttpHeaders.Add(String name, IEnumerable`1 values)
   at WireMock.Http.HttpClientHelper.<SendAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at WireMock.Server.FluentMockServer.<ProxyAndRecordAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at WireMock.Mapping.<ResponseToAsync>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at WireMock.Owin.WireMockMiddleware.<Invoke>d__5.MoveNext()

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 25

Commits related to this issue

Most upvoted comments

Ah. Maybe I understand you problem:

When WireMock is in Proxy-mode (ProxyAndRecordSettings defined), it can only be used for that purpose.

The idea is that when you are done proying & recording, you must start and use WireMock in a normal way.

Ok. The latest code from yesterday should fix some issues with headers. However I am not sure I ever tested something else then GET… Will have to check.