# How to handle a incoming HTTP POST in the graylog API

**URL:** <https://community.graylog.org/t/how-to-handle-a-incoming-http-post-in-the-graylog-api/1895>\
**Category:** Development\
**Created:** [July 31, 2017, 6:12pm UTC](https://community.graylog.org/t/how-to-handle-a-incoming-http-post-in-the-graylog-api/1895 "2017-07-31T18:12:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pbrocker](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/pbrocker/32/889_2.png) [@pbrocker](https://community.graylog.org/u/pbrocker)\
**Post date:** [July 31, 2017, 6:12pm UTC](https://community.graylog.org/t/how-to-handle-a-incoming-http-post-in-the-graylog-api/1895/1 "2017-07-31T18:12:38Z")

</div>

Is there a specific example or way you suggest to handle a incoming HTTP post!? I am uploading a file (image) from the frontend and have written a working API Post route (localhost:9000/api/org.plugins.logo-replacer/uploadLogo). But I am having trouble allowing the function I created to parse the data. I do not want to have to include other resources such as HttpServlet jar. What would you recommend being the best way to consume a API Post call!?

Frontend Code:

```auto
  _saveConfig(e) {
    let data = this.refs.logoReplacerConfigModal.refs.form.elements[1].files[0];
    let fd = new FormData();
    fd.append('image', data);
    this.props.updateConfig(this.state.config).then(() => {
      fetch('http://localhost:9000/api/plugins/org.graylog.plugins.logo/uploadLogo', {
        method: 'POST',
        // headers: {
        // 'Content-Type': 'multipart/form-data',
        // },
        body: fd
      })
      .then(function(response) {
        console.log('success');
        this._closeModal();
      });
    });
  }

```

Backend Code:

```auto
    @POST
    @Timed
    @ApiOperation(value = "Upload Logo")
    @NoAuditEvent("only used to upload a new image to graylog")
    public void upload(HttpServletRequest request) {
        LOG.info("");
    }

```

---

<div class="post-metadata">

**Author:** ![jochen](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/jochen/32/8_2.png) [@jochen](https://community.graylog.org/u/jochen)\
**Post date:** [August 1, 2017, 11:26am UTC](https://community.graylog.org/t/how-to-handle-a-incoming-http-post-in-the-graylog-api/1895/2 "2017-08-01T11:26:43Z")

</div>

Since the HTTP resources for Graylog are “normal” JAX-RS classes, I recommend reading the [Jersey User Guide](https://jersey.github.io/documentation/2.25.1/index.html).

Using `HttpServletRequest` is unnecessarily low-level. You can directly use an `InputStream` or `byte[]` if you’re uploading binary data.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/graylog/original/3X/c/7/c7c09c6b5099570133d6502b83f50ba4430de5b6.png) [@system](https://community.graylog.org/u/system)\
**Post date:** [August 15, 2017, 11:26am UTC](https://community.graylog.org/t/how-to-handle-a-incoming-http-post-in-the-graylog-api/1895/3 "2017-08-15T11:26:44Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
