- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I am trying to upload the binary file below is the code, it keep failing with Bad request error, please suggest what could be the issue.
HttpPost httpPost = new HttpPost(attachmenturi);
if (!byPassProxy) httpPost.setConfig(config);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
FileBody bin = new FileBody(attachfile,ContentType.DEFAULT_BINARY);
StringBody stringBody1 = new StringBody("incident", ContentType.MULTIPART_FORM_DATA);
StringBody stringBody2 = new StringBody("c8c3ba6643333a4073a1433e0210c706", ContentType.MULTIPART_FORM_DATA);
builder.addPart("table_name", stringBody1);
builder.addPart("table_sys_id", stringBody2);
builder.addPart("f", bin);
HttpEntity entity = builder.build();
httpPost.setEntity(entity);
{
"assignment_group": "378e2fa9374c6200772863d2b3990e0d",
"attachment_flg": true,
"attachment_name": "Lottery.jpg",
"attachment_path": "e://temp//Lottery.jpg",
"batch": true,
"description": "PPlease find attached, the Q05 GWP Client Site Monthly Response Time Report",
"due_date": "20190506",
"group_list": "378e2fa9374c6200772863d2b3990e0d",
"inc_id": "string",
"inc_source": "string",
"priority": "3",
"short_description": "TTesting",
"user": "ssaif",
"watch_list": "378e2fa9374c6200772863d2b3990e0d"
}