java - HTTP 500 code during JSON file upload -
i getting server error code 500 while trying upload json file server.the problem occurs because of parameters. when use plain json string, without multipart builder, works. code use below
many in advance
public void uploadsegmentcustomerlist(file jsonfile, string segmentid) throws ioexception { if(this.apiclient.gettoken() == null){ apiclient.login(); } multipartentitybuilder builder = multipartentitybuilder.create(); builder.setmode(httpmultipartmode.browser_compatible); httppost uploadpost = new httppost(restconfig.getbaseurl() + restconfig.getuploadurl().replace("@segmentid@",segmentid)); uploadpost.setheader("sessiontoken", this.apiclient.gettoken()); // attaches file post: file f = jsonfile; builder.addbinarybody("test" , new fileinputstream(f), contenttype.application_json,f.getname() ); httpentity multipart = builder.build(); uploadpost.setentity(multipart); httpresponse response = apiclient.uploadpost(uploadpost); int responsecode = response.getstatusline().getstatuscode(); log.info(string.valueof(response)+ " "+ responsecode); }
Comments
Post a Comment