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.

Document POST body example

See original GitHub issue

After a bunch of experimentation, I figured out that you can use a POJO as a POST body, but I couldn’t find it anywhere in the documentation. e.g. You can do

public interface Boop {
    @RequestLine("POST /boop/{someParam}")
    @Headers({
        "Accept: application/json",
        "Content-Type: application/json"
    })
    BoopResponse createBoopUsingPOST(Boop boop, @Param("someParam") String someParam);

    class Boop {
        public String value;
    }
}

But the tricky part is that the POJO param (boop, in the example), must come first in the parameter list of the method. That was difficult to find out!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
kdavisk6commented, May 23, 2019

@wulftone

Thanks for this example. It is missing from the documentation. You can define the body of the request two ways:

  • annotating the parameter with @Body
  • the first method parameter without an annotation is assumed to be the Body

We should update the documentation to explain this and add you example.

0reactions
eiselemscommented, Jun 4, 2020

@sleroy hoped the example would be sufficient

  @RequestLine("POST /repos/{owner}/{repo}/issues")
  void createIssue(Issue issue, @Param("owner") String owner, @Param("repo") String repo);

How should we improve it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Describing Request Body - Swagger
Request bodies are typically used with “create” and “update” operations (POST, PUT, PATCH). For example, when creating a resource using POST or PUT,...
Read more >
Add a Request Body to a POST Request | API Connector
Enter a Request Body​​ As part of a POST, PUT, or PATCH request, a data payload can be sent to the server in...
Read more >
POST - HTTP - MDN Web Docs
The HTTP POST method sends data to the server. The type of the body of the request is indicated by the Content-Type header....
Read more >
Request Body - FastAPI
A request body is data sent by the client to your API. ... For example, this model above declares a JSON " object...
Read more >
How do I post request body with Curl? - ReqBin
Click Run to execute Curl POST Body example online and see results. ... The HTTP POST method is used to upload files and...
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