Attachments/REST WS: Error 415 (Unsupported Media Type)

restws
attachments
Tags: #<Tag:0x00007fdb13e49d50> #<Tag:0x00007fdb13e49b20>

(srikanth kh) #21

was trying this locally, but getting ’ cannot find symbol produces error during compilation’. Any pointers?


(Dimitri R) #22

You should always provide as much information as you can, in this case you should paste your compilation log on https://hastebin.com/

Perhaps those @RequestMapping attributes suggested on SO are shipped with a more recent version of Spring, but I’m shooting in the dark here.


(srikanth kh) #23

Sorry, not aware of the procedure. Details available at https://hastebin.com/ohovajuhax.sql


(Dimitri R) #24

This class lives in the submodule omod-common that depends on Core 1.9.x and hence on Spring 3.0.5.RELEASE. Here is the output of mvn dependency:tree:

+- org.openmrs.api:openmrs-api:jar:1.9.10:provided
|  +- org.springframework:spring-core:jar:3.0.5.RELEASE:provided

It looks like ‘produces’ was added to @RequestMapping as of Spring 3.1.0 (see here) ; and it not yet part of Spring 3.0.5, see here). That’s unfortunate.

For the sake of troubleshooting the issue you could make REST WS depend on the same version of Spring that is actually used at runtime. Most likely 4.1.4.RELEASE.


(srikanth kh) #25

Hi @mksd

I tried by removing - headers = “Content-Type=multipart/form-data” - in MainResourceController.java - basically not forcing any content type. It worked :slight_smile:

Thanks and let me know what to do with this change


(Dimitri R) #26

You would need to create a bug ticket for this in RESTWS.

The ticket would have to explain what exactly your fix aims at solving. My guess is that MainResourceController enforces that the upload content type is multipart/form-data. On the other hand it remains loose on what the accepted content is (= it does not specify the Accept header). So perhaps, when requests come in with a mismatched Accept header an error 415 is thrown.

You would have to confirm all this before creating the ticket.

@raff, I wonder if you could skim through hereup and confirm whether my thinking makes sense?


(Rafal Korytkowski) #27

It should be okay to skip headers. Spring should put correct headers given MultipartFile is expected as a parameter.


(Dimitri R) #28

Ok good. @kshebbar can you create that ticket in the RESTWS Jira project?


@raff do you think that this is what might have happened:


(Rafal Korytkowski) #29

Yes, I think so. However, the server OS shouldn’t matter rather the client OS / browser. From the thread it’s unclear to me, if @kshebbar used always the same client.


(srikanth kh) #30

yes, I always used the same client. When the server was in Windows, did not face any issues, but had issues when hosted on cent OS.