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.

Pass arbitrary JSON objects in request body

See original GitHub issue

How can I pass JSON objects with arbitrary structure in the body of a request? For responses, it is possible to just specify application/json: {} but that seems not to work for request bodies. Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jdegrecommented, Jun 25, 2021

Not sure if the OP really meant “arbitrary JSON objects”, as in the title of the issue. If it was meant “JSON objects”, I guess the right schema for the request body would be:

application/json:
  schema:
    type: object

Otherwise, the schema mentioned above (schema: {}) would be satisfied by, e.g., an array, a boolean, a string… well, anything, as long as it is valid JSON.

1reaction
karenetheridgecommented, Jun 25, 2021

This raises an interesting point – how does one specify “the body can be anything at all, including being empty”? An empty body is not valid json. Or, as a corollary: how does one specify “there should not be a body; if there is anything, this is a violation”? Perhaps there is a FAQ or cookbook that I have not found yet 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Accept arbitrary JSON as RequestBody in Spring
You can receive a JsonNode object for an arbitrary JSON. Like this: @RequestMapping(value = "test/data", method = RequestMethod.POST ...
Read more >
Java – Accept arbitrary JSON as RequestBody in Spring
Is there a simple solution to receiving arbitrary, nested JSON data as part of the RequestBody , or am I forced to either...
Read more >
Arbitrary JSON data in API reference
Hi, we have an API endpoint that can take arbitrary JSON in a part of its request body. We tried to express that...
Read more >
Describing Request Body
The requestBody is more flexible in that it lets you consume different media types, such as JSON, XML, form data, plain text, and...
Read more >
JSON - HTTPie 3.2.1 (latest) docs
If your use case involves sending complex JSON objects as part of the request body, HTTPie can help you build them right from...
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