Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Unable to pass the JSON object to the REST PUT API

Ravi Nagubandi-OracleOct 25 2017 — edited Oct 26 2017

Hi,

I'm using Oracle JET Version - 3.2.0

I'm new to the Javascript space. I'm working on implementing the CRUD pattern using Oracle JET and Java based REST API.

I'm trying to update the data in UI and invoke the REST PUT method, but not able to pass the JSON object.

Here is my REST API:

    @PUT

    @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})

    public void edit(TelephoneNumber entity) {

        super.edit((TelephoneNumber) entity);

    }

Here is my Javascript code:

self.update = function(data)

{

     var currentRow = $("#table").ojTable("option", "currentRow");

     if (currentRow !== null) {

         var collection = data.TNCol();

         var model = collection.get(currentRow['rowKey']);

         var recordAttrs = {Description: model.get('Description')};

         $.ajax({

             type: "PUT",

             url: testURL = self.serviceURL,

             data: JSON.stringify(recordAttrs),

             contentType: "application/json",

             success: function (data, textStatus, xhr) {

                   console.log(data);

             },

             error: function (xhr) {

                  alert(xhr.responseText);

             }

       });

}

};

Any inputs would be helpful.

Regards

Ravi

Comments
Post Details
Added on Oct 25 2017
6 comments
696 views