Hi Jon,

If you are using the master branch, you can create a RestActionBean which
will take the incoming JSON and parse it into ActionBean fields.

If you are not using the master branch, you can a @Before method on your
ActionBean which is executed before binding and validation.  That method
extract take the json from the request body and set it on your ActionBean.
Something like the following:

public class SparkActionBean implements ActionBean {
  private String jsonString;

  @Before(LifecycleStage.BindingAndValidation)
  public void getRequestBody() {
    StringBuffer requestBody = new StringBuffer();
    String line = null;
    try {
        BufferedReader reader = getContext().getRequest().getReader();
        while ((line = reader.readLine()) != null)
            body.append(line);
    } catch (Exception e) {
    }

    setJsonString( requestBody.toString() );
  }

  @DefaultHandler
  public Resolution ingestEmail() {
    someMethodToParseJsonString();
    return ...;
  }
}


Good luck!

-- Rick

On Thu, Apr 20, 2017 at 12:04 PM, Heather and Jon Turgeon <
tashiba40_evergr...@hotmail.com> wrote:

> Hi all, I am trying to use SparkPost Relay Webhooks to accept emails, then
> forward on the content to a ActionBean for processing. I have the
> forwarding worked out but SparkPost is posting a "raw body" JSON object to
> the ActionBean. I have never used an ActionBean like this, I usually expect
> parameters with values. Anyway, is there a way for a Stripes ActionBean to
> accept this? Thanks for any help.
>
>
> Jon
>
>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Stripes-users mailing list
> Stripes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Stripes-users mailing list
Stripes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to