2016-09-30 9 views
0

JHipsterでレストスプリングサービスを公開する際に問題が発生しています。 このサービスには、MultipartFile、パラメータ、およびJSONオブジェクトが含まれています。JHipster、MultiPartとJSONを使用したスプリングレストサービス、swagger/curlエラー

public @ResponseBody 
    ResponseEntity<DocumentId> addDoc(@RequestPart(required = true) MultipartFile file, @RequestPart(required = false) String folder, @RequestPart(required = true) MetadataDoc metadata) 

闊歩APIは、「未定義の」データ型として宣言パラメータ「メタデータ」を認識しない次のように私の知る限りでは、私は公開することができるはずです。私はカールの要求を作るしようとすると、私は次のエラーを取得する:

2016-09-30 13:27:15.174 WARN 30451 --- [ XNIO-2 task-12] .m.m.a.ExceptionHandlerExceptionResolver : Resolved exception caused by Handler execution: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'text/plain;charset=UTF-8' not supported 
2016-09-30 13:27:15.298 DEBUG 30451 --- [ XNIO-2 task-14] c.q.smartgov.aop.logging.LoggingAspect : Enter: com.queres.smartgov.web.rest.errors.ExceptionTranslator.processRuntimeException() with argument[s] = [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'text/plain;charset=UTF-8' not supported] 
2016-09-30 13:27:15.298 DEBUG 30451 --- [ XNIO-2 task-14] c.q.smartgov.aop.logging.LoggingAspect : Exit: com.queres.smartgov.web.rest.errors.ExceptionTranslator.processRuntimeException() with result = <500 Internal Server Error,[email protected],{}> 

カール要求:私は多くのことを試してみました

curl -X POST --header 'Content-Type: multipart/form-data' --header 'Accept: application/json' --header 'Authorization: Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsImF1dGgiOiJST0xFX0FETUlOLFJPTEVfVVNFUiIsImV4cCI6MTQ3Njk3NjY3N30.82FRMRSrrniEQcIhI6DtHEFf5ln3OSjS_6OWy-1d8h3Cp5MjRuxo04IuIxAX_WC8YJJ1QyLrq7loLUSQ8RV_Gw' -F [email protected]"result.txt" -F folder=folde -F metadata={"clave":"2","valor":"1"} 'http://127.0.0.1:8080/sd_api/api/almacen/addDoc' 

、どんな提案?

ありがとうございます!

答えて

0

最後に、私はJSONパラメータをStringとして宣言して、それを自分で解析しました。

誰かがこのパラメータをJSONオブジェクトとして公開する方法を知っていれば、私はどのような手掛かりにも感謝します。

ObjectMapper mapper = new ObjectMapper(); 
     try { 
      return mapper.readValue(stringValue, mapper.getTypeFactory().constructCollectionType(List.class, MetadataDoc.class)); 
     } catch (IOException ex) { 
      //throw exception 
     } 
関連する問題