Appconomy_Suppo
14 years agoOccasional Contributor
Issue when posting an image to our REST service using SoapUI
We are running into issues posting an image to our REST services thru SoapUI. No matter what we try, our REST service rejects the SoapUI call, throwing a nullPointerException. Right now, we are not sure if it is our application or SoapUI.
I would very much appreciate it if you could give our SoapUI request a quick look to see if there is something obvious we are doing wrong - see attached screenshot. We have looked at various posts on the forum but could not find anything that would address this specific issue.
In addition, here is the unit test code for the REST service that handles image uploads:
Any help is very much appreciated
I would very much appreciate it if you could give our SoapUI request a quick look to see if there is something obvious we are doing wrong - see attached screenshot. We have looked at various posts on the forum but could not find anything that would address this specific issue.
In addition, here is the unit test code for the REST service that handles image uploads:
ClientResponse response =
createImage("v1/merchants/"+merchant.getId().toString()+"/images",
"/test/com/appconomy/matrix/restclient/coupon/logo.jpg",
"image/jpeg");
protected ClientResponse createImage(String resourcePath, String
filename, String contentType) throws Exception {
byte[] bytes = getFileBytes(filename);
FormDataMultiPart form = new FormDataMultiPart()
.field("name", filename)
.field("contentType", contentType);
FormDataBodyPart fdp = new FormDataBodyPart("file", bytes,
MediaType.APPLICATION_OCTET_STREAM_TYPE);
form.bodyPart(fdp);
ClientResponse response = regularUserResource.path(resourcePath)
.header("Authorization", authentication)
.type(MediaType.MULTIPART_FORM_DATA_TYPE)
.post(ClientResponse.class, form);
return response;
}
Any help is very much appreciated