java - Error sending object to JAX-RS using JQuery and JSON -


I am trying to send a JavaScript object to a JAX-RS server.

  // JAX-RS server @ septum @ or path ( "/ Edit / Edit" {project_key} / ") @Consumes ({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public reaction editAssociation (@PathParam ( "project_key") string projectKey, @FormParam ( "Union") EditFieldAssociationModel Union) {// TODO // here I just put a debug breakpoint returns response. No content (). build ();} // EditFieldAssociationModel class @XmlRootElement (name = "EditFieldAssociationModel") @XmlAccessorType (XmlAccessType.FIELD) public class EditFieldAssociationModel {@XmlElement (name = "id") private Long id; @ Aksmelelimen (Name = "method") private String method; @ Aksmelliment (name = "Jira default value") private String Jira default value; @ XmlElement (name = "externalDefaultValue") private String externalDefaultValue; // and public Aksesrs}   

and my JS code:

  function () {var editasso = {id: asso_id, method: d.find (".cync-plugin-method") Find ('Select'). Val (), jiraDefaultValue: d.find ('sync-plugin-jira-default-value'). ('Choose'). ), External default value: D.Find ('.sink-plugin-external-default-value'). ('Choose'). Val ()}; .. AJS $ ajax ({url: AJS.contextPath () + '/ left / one-sync-rest / 1.0 / union / edit / "+ getProjectKey (), type:" put ", // TODO data: JSON. stringify (editasso), beforeSend: function (x) {if (x & amp; & amp; x.overrideMimeType) {//x.overrideMimeType("application/json; charset = UTF-8 "); x.setRequestHeader (" Content-type "," application / json; charset = UTF-8 "); console.log (" mime type override fix "); else {console.log (" Unable to override mime type ")}}, Datatype: "Json", success: function (msg) {dialog.remove (); location.reload ();}, error: sync_plugin_error});}   

I have other values ​​of editasso Of the Tried

  var editasso = {association: {id: asso_id, method: d.find (".co.cc.-plugin-method") ('select') , JiraDefaultValue: '.sink-plugin-jira-default-value' d.find () looks ('select') Val (), externalDefaultValue ..: d.find ('sync-plugin-external-default-value ('Select') Val ()}}.   

The post body looks correct:

  {"association": { "Id": "350", "method": "com. A.jira.synchronization.KeepLatestSyncMethod "," jiraDefaultValue ":" Valeur 1 "," externalDefaultValue ":" aa "}}   

exception

  Org.codehaus.jackson.map.JsonMappingException: can not remove the frequency of java.util.ArrayList from the START_OBJECT token   

any suggestions?

Thx

Problem solving: EditFieldAssociationModel should not use the same annotation compared to server-to-client class. My class looks like this:

  Public category EditFieldAssociationModel {@JsonProperty ("id") Private long id; @Jesnpropper T ("method") Private string method; @JespronProperty ("Zira default value") Private string Jira default value; @Jesonproperty ("external default value") Private string External default value; // getters and setters}   

And it works

Comments