Form via PUT method is not sending the data to a restEasy service

Asked

Viewed 40 times

0

I am sending a form via Ajax, my front is done in Angularjs. I capture the form information and send it to a service that is in Java Restreasy. But it arrives Nullo! Someone could help me?

In my controller this way:

var req = {
         method: 'PUT',
         url: "api/empresa/"+appCtrl.userLogado.id,


         data: {empresa: empresa} ,

         headers: {'Content-Type':'application/x-www-form-urlencoded'}
        };


        $http(req).then(function (response) {

            iziToast.success({
                title: 'Sucesso!',
                message: 'Atualização realizada com sucesso!',

                onClose: function(){
                    $("#divload").hide();
                    $("#loader").hide();



                }


            });

        }, function (error) {

            iziToast.warning({
                message: 'Infelizmente não foi possível fazer a atualização',
                onClose: function() {

                    $("#divload").hide();
                    $("#loader").hide();
                    $("#login-box").show();
                    window.location.href = 'index.jsp';
                }

            });

        });

In my Rest it is so:

@PUT
@Path("/{id}")
@PermitAll
public Response update(@PathParam("id") Long id ,@FormParam("empresa") String empresaJson){

[RESOLVED] In javascript I put JSON.stringify(JSON.parse()) and solved the problem!

  • You debugged "company" in JS before making the request to see if you got any value to send?

  • Yes, it is normal in JS. But in resteasy it is not enough....

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.