X

It's All About the Platform.

Accessing Standard Object Functions Via REST Services

Richard Bingham
Senior Development Manager

 

 

Introduction

In this post we examined how Object Functions written against custom objects are available for use via the RESTful services. The exact same capability applies to standard objects also. In Release 10 all Object Functions can have their exposure explicitly controlled, useful for creating custom interactions with your applications data. In this example we'll use object functions on the Opportunities RESTful service.

Illustrative Example

First I have created a basic Opportunity record. This is important to note because the RESTful web services work using a specific record instance, not the whole REST service collection. This is the same when working with Object Functions on custom objects.

Unlike the SOAP equivalent, the Opportunity REST service does not used the Opportunity ID (OptyId) attribute as its primary lookup value, but focuses on the more visible Opportunity Number attribute. Many other attributes are queryable using the "q=" request URL parameter. My record has the Opportunity Number 41009.

In Application Composer I created an Object Function, and in the Visibility dropdown set it to 'Callable By External Systems'. As you can see the new ExtF2 function has just one line of code that returns a String response, in this case "Hello World".

 

Note that if your user does not have access to the instance
record (i.e. Opportunity 41009) then you'll get the following error, unless
you check the Privileged box to allow access without record/data-related security rules.

ResourceNotFoundException: Could not find the element in the tree. KeyString: 41009 

Next is a quick check on the Opportunity record to ensure it's RESTful APIs are accessible. This can be simply done by using the following URL a web browser to simulate a simple GET request:

  • https://[crmHost].oracleoutsourcing.com/salesApi/resources/latest/opportunities/41009

After submitting the user login credentials when prompted, it shows the record data as expected. Additionally using the describe function it's possible to check the new Object Function is available. This is done using the following URL:

  • https://[crmHost].oracleoutsourcing.com/salesApi/resources/latest/opportunities/41009/describe

The describe result has all the available methods (get, put etc) for the service, and includes the new Object Function with this entry. Note the requestType and method values as these are essential in the request:

 {
  "name" : "ExtF2",
  "resultType" : "string",
  "method" : "POST",
  "requestType" : [ "application/vnd.oracle.adf.action+json" ],
  "responseType" : [ "application/json", "application/vnd.oracle.adf.actionresult+json" ]
 }

Note that whilst this works even with the customization in an unpublished sandbox, if you make subsequent edits to a published Object Function you may need to publish those changes for them to be picked up.

 

Finally this was tested using a REST client utility program (SOAPUI), just for clarity here. As you can see the request (below left) and the resulting response (below right - in red) worked as expected.

Note that internally the invoke action is granted in APM, under the Resources associated with product specific Entitlements. For Opportunities the actions are enabled on the 'Rest Resource - Opportunity' associated with the MOO_VIEW_OPPORTUNITY_PRIV entitlement.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.