title: How to send java object in angular JS
body: <p>I have JS file that is trying to do a POST method, but needs a specific java object as input.</p>
  
  <p>here is the signature of the Post method in the server:</p>
  
  <pre><code>@Path("/branches")
  public class BranchResource {
  
  @POST
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.APPLICATION_JSON)
  public Response post(BranchDescriptor branch) {
  .
  .
  </code></pre>
  
  <p>here is the the JS function (using Angular)</p>
  
  <pre><code>$scope.retry = function() {
      $http({
             url : "rest/branches",
             method : "POST",
             dataType : "json",//not sure is needed
             data : "way to get Branch descriptor "
             headers : {
                   "Content-Type" : "application/json; charset=utf-8",
                   "Accept" : "application/json"
             }
      }).success(function(data) {
             $scope.items = data;
      }).error(function(data) {
             alert('err');
      });
   };
  </code></pre>
  
  <p>I was receiving the following errors:</p>
  
  <pre><code>??? 27, 2014 3:27:48 PM com.sun.jersey.spi.container.ContainerRequest getEntity
  SEVERE: A message body reader for Java class    xxx.api.BranchDescriptor, and Java type class xxx.BranchDescriptor, and MIME media type application/octet-stream was not found.
  The registered message body readers compatible with the MIME media type are:
  application/octet-stream -&gt;
    com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
    com.sun.jersey.core.impl.provider.entity.FileProvider
    com.sun.jersey.core.impl.provider.entity.InputStreamProvider
    com.sun.jersey.core.impl.provider.entity.DataSourceProvider
    com.sun.jersey.core.impl.provider.entity.RenderedImageProvider
  */* -&gt;
  </code></pre>
  
  <p>So, I tried to add a data like that:</p>
  
  <blockquote>
    <p>data : {
                       "_protectedBranch" : "pf_something",
                       "_newBranch" : "some_branch",
                       "_commitId" : "some_commit",
                       "_commiter" : "someone"
                   },</p>
  </blockquote>
  
  <p>and got the following error:</p>
  
  <pre><code>??? 27, 2014 3:42:46 PM com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException
  SEVERE: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container
  org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "_protectedBranch" (Class xxx.BranchDescriptor), not marked as ignorable
   at [Source: HttpInputOverHTTP@66aee27d; line: 1, column: 22] (through reference chain: xxx.BranchDescriptor["_protectedBranch"])
      at org.codehaus.jackson.map.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:53)
  </code></pre>
  
  <p>How can I Pass the BranchDescriptor object for sending?
  What am I missing?</p>