BodyParser Newtonsoft.Json.JsonReaderException
See original GitHub issueDescribe the bug
I keep getting a JsonReaderException when Wiremock is trying to parse a request body. It works on my build server (linux dotnet image), not on my local machine (Windows 10, .NET Core 3.1). I managed to get it working temporarily by deleting the bin folder and rebuilding, but that is no longer working.
I am using xUnit with Microsoft Visual Studio Professional 2019 Version 16.9.3
Expected behavior:
A clear and concise description of what you expected to happen.
Wiremock should read the incoming request and serve the JSON response.
Test to reproduce
The failure is on a GET request
.Given(Request.Create()
.WithPath($"/SomeProjectKey/carts/{cartId}")
.UsingGet())
.RespondWith(
Response.Create()
.WithStatusCode(200)
.WithBodyFromFile("./TestData/GetCart.json")
);
Other related info
Provide additional information if any.
Issue Analytics
- State:
- Created 2 years ago
- Comments:16
Top Results From Across the Web
Newtonsoft.Json.JsonReaderException - vb.net
You are getting this error because you are using JObject.Parse , which expects a single JSON object, but your JSON contains an array....
Read more >Express body-parser middleware
bodyParser.json([options]). Returns middleware that only parses json and only looks at requests where the Content-Type header matches the type option.
Read more >[Solved] Getting error while parsing
Solution 1. Accept Solution Reject Solution. Try this: C#. JArray.Parse(allJsonData["members"].ToString()). Permalink. Share this answer.
Read more >Body-parser middleware in Node.js
Body-parser is the Node.js body-parsing middleware. It is responsible for parsing the incoming request bodies ... app.use(bodyparser.json()).
Read more >Express JS— body-parser and why may not need it
This piece of middleware was called body-parser and used to not be part of the Express framework. The good news is that as...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
No worries. I am glad your issue is solved.
…I think this may have all been a waste of time. Wiremock attempts to deserialize as JSON and catch the JsonReaderException and ignore it. Because I am debugging and have CLR exceptions on it appeared to be a failure, but is actually expected.
Thanks for your time and patience.