How to handle a incoming HTTP POST in the graylog API

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:

  _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) {

Backend Code:

    @ApiOperation(value = "Upload Logo")
    @NoAuditEvent("only used to upload a new image to graylog")
    public void upload(HttpServletRequest request) {"");

Since the HTTP resources for Graylog are “normal” JAX-RS classes, I recommend reading the Jersey User Guide.

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

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