Skip to content

StaplerRequest http body is null #246

@jrichardsz

Description

@jrichardsz

I developed a plugin which receives http body as notifications from gitlab and bitbucket. This plugin is working as expected in previous versions (2020 approximately). Today I installed it on latest version 2.293 and when I send a classic http post with json body using my postman I detected that is empty or null.

Url parameters and headers are detected, but body is null.

Jenkins plugin template use stapler instead native httpservletrequest.

This is my receiver:
https://github.com/software-architect-tools/easy-webhook-plugin/blob/058fadcc95519d2194340628a026203b930bad05/src/main/java/org/jrichardsz/jenkins/plugins/easywebhook/WebHookReceiver.java#L65

And this is how I extract the body:
https://github.com/software-architect-tools/easy-webhook-plugin/blob/058fadcc95519d2194340628a026203b930bad05/src/main/java/org/jrichardsz/jenkins/plugins/easywebhook/WebhookExecutor.java#L28

Thinking that something changed, I updated my plugin with latest jenkins libraries using bitbucket plugin pom.xml as example. This plugin uses the same procedure to get the body. But the error is the same.

Also I tried with:

  • request.getReader().lines().collect(Collectors.joining(System.lineSeparator()));
  • IOUtils.toString(request.getReader());

I will continue my tests.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions