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!

REST calls using ojModel, ojCollection

Andrew Hill-OracleOct 20 2017 — edited Oct 20 2017

JET 3.1

Hi,

I'm attempting to call a REST api using the OjCollection and ojModel however I seem to be having a problem fetching single records.

The code below produces a call which looks like 'http://localhost:7006/../../rest/customers' rather than 'http://localhost:7006/../../rest/customers/100' which I'm expecting.

What am I doing wrong??

Andrew

var CustomerModel = oj.Model.extend({

    idAttribute: 'custId'

});

var CustomerCollection = oj.Collection.extend({

    url: 'rest/customers',

    model: new CustomerModel,

    fetchSize: 25

});

var customers = new CustomerCollection;

var custModel = new CustomerModel({'custId': params.custId}, customers);

var customer  = custModel.fetch({

    success: function(model, response, options) {

        console.log("custModel.fetch success");

    },

    error: function(model, xhr, options) {

        console.log("custModel.fetch error");

    }

});   

This post has been answered by Arjun N-Oracle on Oct 20 2017
Jump to Answer
Comments
Post Details
Added on Oct 20 2017
2 comments
278 views