Hello All,
This is probably a remedial question, but I can't get my object to POST? I
can return my entity via a @GET call, but I can't seem to post it as a form
param. When I execute my POST, I get either an HTTP 415 or 400 error,
depending on what I set for @Consumes
My object is a bean
@XmlRootElement
public class MyDocumentType implements Serializable{
//some fields and getters and setters.
}
Here's my service:
@POST
@Path(DOC)
@Consumes("application/xml")
public String updateDocument(@HeaderParam(SESSION_ID_HEADER_KEY) String
sessionId,
@FormParam(DOC_OBJ) MyDocumentType doc) {
confirmSessionIsValidAndAuthorIsLoggedIn(sessionId, doc);
storeService.updateDocument(doc);
return "SUCCESS: " + doc.getId();
}
Here's my client:
Client client = new Client();
resource = client.resource(serverURL);
final WebResource finalPath = resource.path(path);
Form form = new Form();
form.add("doc", doc);
return finalPath.type("application/xml").header(SESSION_ID_HEADER_KEY,
sessionId).post(String.class, form);
I get an HTTP 400 with that combination.
I think my bean is OK as I can retrieve a MyDocumentType via @GET.
When I call:
return
finalPath.type(MediaType.APPLICATION_FORM_URLENCODED).header(SESSION_ID_HEADER_KEY,
sessionId).post(String.class, form);
with
@Consumes("application/x-www-form-urlencoded")
on the service, I get:
SEVERE: A message body reader for Java type, class MyDocumentType, and MIME
media type, application/x-www-form-urlencoded, was not found
Is there something I'm missing? Any help would be greatly appreciated:
Thanks,
Steven
Harvard Children's Hospital Informatics Program
--
View this message in context: http://n2.nabble.com/Jersey-Client%3A--How-can-I-POST-an-object---I%27m-getting-an-HTTP-415-error.-tp2324279p2324279.html
Sent from the Jersey mailing list archive at Nabble.com.