I am building a document management service with a RESTful API.

public class FileUploadService
  public Response uploadFile(@FormDataParam("file") InputStream fileStream,
          @FormDataParam("file") FormDataContentDisposition fileDetail) throws IOException

It seems to work as expected if I use a third party client such as Postman. However, when using the REST activity of ivy I am unable to call this service. I always get errors stating the the header X-Requested-By is missing. Whats the issue? How can I send files using a REST Client Call activity?

asked 18.04.2019 at 04:05

SupportIvyTeam's gravatar image

SupportIvyTeam ♦♦
accept rate: 77%

edited 18.04.2019 at 04:27

Hi. The problem with X-Requested-By is that it shows up a lot even if it's not the problem. This issue was fixed in XIVY-3097. So if you are sending a modyfing request like PUT or POST and you are sure that you set X-Requested-By Header then it's other issue. What your problem probably is, is that you need to set MediaType boundary like

MediaType contentType = MediaType.MULTIPART_FORM_DATA_TYPE;
contentType = Boundary.addBoundary(contentType);

and use it in your entity as content-type. And it will not work if you use MediaType.MULTIPART_FORM_DATA_TYPE instead of contentType


MediaType contentType = MediaType.MULTIPART_FORM_DATA_TYPE;
contentType = Boundary.addBoundary(contentType);

Response apacheConnectorResponse = client
        .header("X-Requested-By", "ivy")
        .put(Entity.entity(createMultipart(realPdf), contentType));

You are able to see the full example in ConnectivityDemos (7.3 and newer) > rest > FileUpload


answered 18.04.2019 at 04:19

Jacek%20Lajdecki's gravatar image

Jacek Lajdecki
accept rate: 66%

edited 06.09.2019 at 02:36

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 18.04.2019 at 04:05

Seen: 642 times

Last updated: 06.09.2019 at 02:36