Reputation: 305
I am a newbie to IBM MobileFirst, I am trying to upload an image using Multipart. Whenever I try to call the API to upload image I get an error in the Postman saying 415 content not found or 500 server error. So I just wanted to know does IBM mobile first java adapter accepts multi-part requests?
I have attached the Java code used , but none of these are working:
1)
@RequestMapping(value = "/uploadFile", method = RequestMethod.POST)
public @ResponseBody
String uploadFileHandler(@RequestParam("file") MultipartFile file)
{
return null;
}
tried this also :
@POST
@Path("/upload")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@OAuthSecurity(enabled=false)
public ResponseEntity<?> upload(@RequestParam("files") MultipartFile files) {
log.info("XXXXXXXXXXXXXXXXXXXX");
return null;
}
@POST
@Path("/addEmployeeAttachment")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.MULTIPART_FORM_DATA)
@OAuthSecurity(enabled=false)
public @ResponseBody Map<String, Object> addEmployeeAttachment(
@RequestParam(required = false, value = "attachmentFile") MultipartFile attachmentFile) {
log.info("xxxxxxxxxx");
return null;
}
Upvotes: 0
Views: 167
Reputation: 2523
With reference to IBM Mobile first development reference document https://www.ibm.com/support/knowledgecenter/SSHS8R_8.0.0/com.ibm.worklight.apiref.doc/apiref/c_restapi_oview.html
We can use Deploy (POST)
for Deploys a multipart compressed file.
JSON example:-
{
"ok" : false,
"productVersion" : "8.0",
"transaction" : {
"appServerId" : "Tomcat",
"description" : {
"name" : "myname",
"type" : "mytype",
},
"errors" : [
{
"details" : "An internal error occured.",
},
...
],
"id" : 1,
"project" : {
"name" : "myproject",
},
"status" : "FAILURE",
"timeCreated" : "2014-04-13T00:18:36.979Z",
"timeUpdated" : "2014-04-14T00:18:36.979Z",
"type" : "UPLOAD_ARTIFACT",
"userName" : "demouser",
},
}
Standard Error code:-
Errors 400 No deployable data is provided. 403 The user is not
authorized to call this service. 404 The corresponding runtime is not
found or not running. 500 An internal error occurred.
Could you pleas refer How can I make a multipart/form-data POST request using Java? as well.
I hope it will help you to understand more about multipart API.
Upvotes: 0