question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BodyParser Newtonsoft.Json.JsonReaderException

See original GitHub issue

Describe 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.

image

image

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:closed
  • Created 2 years ago
  • Comments:16

github_iconTop GitHub Comments

1reaction
StefHcommented, Aug 20, 2021

No worries. I am glad your issue is solved.

0reactions
Glen-Moonpigcommented, Aug 20, 2021

…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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found