title: Call WS Rest Java with AngularJS
body: <p>I've a problem with call WS Rest Java. I call the WS but the parameters isn't passed. </p>
  
  <p>My java code:</p>
  
  <pre><code>@POST
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
  public Response setUser(@FormParam("name") String name, @FormParam("surname") String surname, @FormParam("email") String email,
                          @FormParam("phone") String phone, @FormParam("skype") String skype, @FormParam("password") String password){
      try {
          FileOutputStream fis =  new FileOutputStream("/home/File.txt");
          PrintStream ps = new PrintStream(fis);
          String s = "name: "+name+"\nSurname: "+surname+"\nEmail: "+email+"\nPhone: "+phone+"\nSkype: "+skype+"\nPassword: "+password;
          ps.println(s);
          ps.close();
          fis.close();
          UserDAO userdao = new UserDAO(0,name,surname,email,phone,skype);
          userdao.save();
          ...
          return Response.status(200).entity(new ObjectMapper().writeValueAsString("OK!")).header("Access-Control-Allow-Origin", "*").build();
      } catch (Exception e) {
          e.printStackTrace();
          return Response.status(500).entity("ERROR!").header("Access-Control-Allow-Origin", "*").build();
      }
  }
  </code></pre>
  
  <p>Angular call:</p>
  
  <pre><code>data = {
      name: $scope.reg_name,
      surname: $scope.reg_surname,
      email: $scope.reg_email,
      phone: $scope.reg_phone,
      skype: $scope.reg_skype,
      password: $scope.reg_password
    }
  $http.post(baseUrl+'user/',data,{
      headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
    });
  </code></pre>
  
  <p>If i log data on angular data are set, the call working but i've an error when i create AccountDAO object because the parameters are null. To test the parameters values i create a file and put here the value, the content are this:</p>
  
  <blockquote>
    <p>name: null</p>
    
    <p>Surname: null</p>
    
    <p>Email: null</p>
    
    <p>Phone: null</p>
    
    <p>Skype: null</p>
    
    <p>Password: null</p>
  </blockquote>
  
  <p>Any one have idea why not pass the parameters?</p>
  
  <p>Thanks!</p>
  
  <p>Solved:</p>
  
  <pre><code>data = "name=" + $scope.reg_name +
  "&amp;surname=" + $scope.reg_surname +
  "&amp;email=" + $scope.reg_email +
  "&amp;phone=" + $scope.reg_phone +
  "&amp;skype=" + $scope.reg_skype +
  "&amp;password=" + $scope.reg_password;
    }
  $http.post(baseUrl+'user/',data,{
  headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
    })
  </code></pre>
  
  <p>Thanks grizzly!</p>