Hi All,
I am using MbDotNet to create an imposter in a c# test. The below code creates a Mountebank client and then uses it to add a Stub that returns HttpStatusCode.OK and a response body that I am reading from a json file. The stub is created successfully. But when I use Postman or my c# code to make a call to the imposter, I get error:
****
{"level":"error","message":"[http:3000] ::1:65440 X=> {\"code\":\"ERR_HTTP_INVALID_STATUS_CODE\",\"message\":\"Invalid status code: ok\",\"name\":\"RangeError\",\"stack\":\"RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: ok\\n at ServerResponse.writeHead (_http_server.js:259:11)\\n at Server.<anonymous> (C:\\\\Users\\\\RSen\\\\AppData\\\\Roaming\\\\npm\\\\node_modules\\\\mountebank\\\\src\\\\models\\\\http\\\\baseHttpServer.js:136:26)\\n at processTicksAndRejections (internal/process/task_queues.js:95:5)\"}","timestamp":"2022-01-06T23:04:11.245Z"}
****
My c# code to add imposter is below. This has worked previously in a different project but for some reason is failing now. Is there a way for me to see more details in the log when creating and calling this imposter?
****
var mbClient = new MountebankClient();
var sitesImposter = mbClient.CreateHttpImposter(3000);
sitesImposter
.AddStub()
.ReturnsBody(HttpStatusCode.OK, File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "Stubs", "siteImposter.json")));
mbClient.Submit(sitesImposter);
****
Help is much appreciated.