2
votes

I have a Jersey based REST API and its signature looks like this

@POST
    @Path("{businessId}/logo/add/")
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    @Produces(MediaType.TEXT_PLAIN)
    public Response uploadLogo(
        @PathParam("businessId") String businessId,
        FormDataMultiPart form
    ) {
......

I tried several curl command lines in order to try to upload an image file using the REST api. But i cant seem to make it work. I am getting 415. I understand 415 error code, but i cant figure out whats going on. Content-Type in my request is correct ( multipart/form-data )

curl -i -X POST -F "imageFile=./image.jpg" http://myserver.com:8080/admin/02D0828864100000000B28C545B728F4/icon/add -v

POST /admin/02D0828864100000000B28C545B728F4/icon/add HTTP/1.1 User-Agent: curl/7.30.0 Host: myserver:8080 Accept: / Content-Length: 176 Expect: 100-continue Content-Type: multipart/form-data; boundary=----------------------------c3081bfebd64

< HTTP/1.1 100 Continue
HTTP/1.1 100 Continue
< HTTP/1.1 415 Unsupported Media Type
HTTP/1.1 415 Unsupported Media Type
< Content-Length: 0
Content-Length: 0
* Server Jetty(9.1.z-SNAPSHOT) is not blacklisted
< Server: Jetty(9.1.z-SNAPSHOT)
Server: Jetty(9.1.z-SNAPSHOT)

* HTTP error before end of send, stop sending
< 
* Closing connection 0
1
Same problem, have you ever solved it?Eduardo

1 Answers

0
votes

have you tried with the content type

curl -H "Content-Type:multipart/form-data" -i -X POST -F "imageFile=./image.jpg" http://myserver.com:8080/admin/02D0828864100000000B28C545B728F4/icon/add -v

?