Manage Oracle CX Records
Get Your Oracle CX Version
First, let's get the REST API versions supported by your instance of Oracle CX.
Send a GET request using the following URL for a list of supported versions.
Example URL
Method: GET
https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/
Example Response
Here's an example of the response body in JSON format.
{ "items": [ { "version": "11.13.18.05", "isLatest": true, "adf:extension": { ... }, "links": [], }, { "version": "11.13.17.11", "adf:extension": { ... }, "links": [], }, { "version": "11.13.17.08", "adf:extension": { ... }, "links": [], }, ... }
For the next set of sample tasks,
let's use 11.13.18.05
as
the version.
Get Your List of Resources
Next, let's programmatically get a list of resources available in your version of the Oracle CX service. To get the list, send a GET request with the following URL.
Example URL
Method: GET
https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/describe
Notice that we are
getting the list of resources in the crmRestApi
container associated with Oracle CX.
Example Response
Here's an example response with the list of resources that you can access:
{ "Resources": { "competitors": { ... }, "wrapUps": { ... }, "presentationSessions": { ... }, "activities": { ... }, "opportunities": { ... }, ... }
Note the resource that you want to work with. For the next set of sample tasks, we will work with the Opportunities resource.
Create Your Record
Let's get started by creating an opportunity using the Opportunities resource.
We will use the POST method to create an opportunity with the name Big Data Analytics Servers.
For other resources, see their respective Create section to know the attributes required for create. The section would also have sample request and response.
Example URL
Use this resource URL format.
Method: POST
https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/opportunities
Example Request
Here's an example of the request body in JSON format.
{ "Name" : "Big Data Analytics Servers" }
Example Response
Here's an example of the response body in JSON format.
{ "items": [ { "BudgetAvailableDate": null, "BudgetedFlag": false, "PrimaryOrganizationId": 204, "ChampionFlag": false, "CreatedBy": "SALES_ADMIN", "CreationDate": "2018-01-08T12:00:24.972+00:00", "CurrencyCode": "USD", "SalesMethodId": 300100073102472, "SalesStageId": 300100073102473, "CustomerAccountId": null, "DealHorizonCode": null, "DecisionLevelCode": null, "Description": null, "LastUpdateDate": "2018-01-08T12:24:05.310+00:00", "LastUpdatedBy": "SALES_ADMIN", "LastUpdateLogin": "6242B5ED93BE3EC9E0539EBDF20ABB8B", "Name": "Big Data Analytics Servers", "OptyId": 300100125332293, "OptyNumber": "CDRM_93472", "OwnerResourcePartyId": 100010025532672, "PrimaryCompetitorId": null, "KeyContactId": null, "ReasonWonLostCode": null, "RiskLevelCode": null, "StatusCode": "OPEN", "StrategicLevelCode": null, "PrimaryRevenueId": 300100125332294, "TargetPartyId": 300100125332282, "TargetPartyName": "Vision Corporation", "SalesMethod": "Sales Process", "SalesStage": "Stage1", "DescriptionText": "Stage1", "AverageDaysAtStage": null, "MaximumDaysInStage": null, "PhaseCd": "QUALIFICATION", "QuotaFactor": 0, ... }
You will also get the response code 201, which indicates that the record has been created.
You might need to run some business processes when you create a record. These processes aren't automatically run when you create a record through REST API. It's recommended that you schedule such processes to run daily. This would ensure that the business processes are run all records created through REST APIs.
Get Your Record
Now, let us get the opportunity record we just created.
Before you get the record, you need to know the unique identifier of that record. You can get that by listing all the records for the resource.
We will use the GET method with this URL to list all the Opportunity records.
Example URL
Use this resource URL format.
Method: GET
https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/opportunities
Example Response
Here's an example of the response body in JSON format, with a list of opportunities that you can access:
{ "items": [ { "BudgetAvailableDate": null, "BudgetedFlag": false, "PrimaryOrganizationId": 204, "ChampionFlag": false, "CreatedBy": "SALES_ADMIN", "CreationDate": "2018-01-08T12:00:24.972+00:00", "CurrencyCode": "USD", "SalesMethodId": 300100073102472, "SalesStageId": 300100073102473, "CustomerAccountId": null, "DealHorizonCode": null, "DecisionLevelCode": null, "Description": null, "LastUpdateDate": "2018-01-08T12:24:05.310+00:00", "LastUpdatedBy": "SALES_ADMIN", "LastUpdateLogin": "6242B5ED93BE3EC9E0539EBDF20ABB8B", "Name": "Big Data Analytics Servers", "OptyId": 300100125332293, "OptyNumber": "CDRM_93472", "OwnerResourcePartyId": 100010025532672, "PrimaryCompetitorId": null, "KeyContactId": null, "ReasonWonLostCode": null, "RiskLevelCode": null, "StatusCode": "OPEN", "StrategicLevelCode": null, "PrimaryRevenueId": 300100125332294, "TargetPartyId": 300100125332282, "TargetPartyName": "Vision Corporation", "SalesMethod": "Sales Process", "SalesStage": "Stage1", "DescriptionText": "Accelerated sales process - stage 1", "AverageDaysAtStage": null, "MaximumDaysInStage": null, "PhaseCd": "QUALIFICATION", "QuotaFactor": 0, ..., }, { "BudgetAvailableDate": null, "BudgetedFlag": false, "PrimaryOrganizationId": 204, "ChampionFlag": false, "CreatedBy": "SALES_ADMIN", "CreationDate": "2018-01-03T04:02:30.801+00:00", "CurrencyCode": "USD", "SalesMethodId": 300100073102472, "SalesStageId": 300100073102473, "CustomerAccountId": null, "DealHorizonCode": null, "DecisionLevelCode": null, "Description": null, "LastUpdateDate": "2018-01-03T04:04:37.956+00:00", "LastUpdatedBy": "SALES_ADMIN", "LastUpdateLogin": "61D4E597C30B4BA8E0539EBDF20A589F", "Name": "SaSS Application Suite", "OptyId": 300100125073393, "OptyNumber": "CDRM_91468", "OwnerResourcePartyId": 100010025532672, "PrimaryCompetitorId": null, "KeyContactId": null, "ReasonWonLostCode": null, "RiskLevelCode": null, "StatusCode": "OPEN", "StrategicLevelCode": null, "PrimaryRevenueId": 300100125073394, "TargetPartyId": 300100124384171, "TargetPartyName": "Pinnacle Technologies", "SalesMethod": "Sales Process", "SalesStage": "Stage4", "DescriptionText": "Awaiting closure.", "AverageDaysAtStage": null, "MaximumDaysInStage": null, "PhaseCd": "QUALIFICATION", "QuotaFactor": 0, ..., }, ...
You need to scroll through the list of opportunities and find the opportunity you want to use and make a note of its path parameter value. A path parameter is a unique identifier of a record. We use it to specify the record on which to perform the get, update, or delete methods. Here, the path parameter is Opportunity Number (OptyNumber). For more information about path parameters of a resource, see All REST Endpoints.
We can then see all the available records for the resource. You need to identify the record that you want to use and note its path parameter value. In our example, the path parameter is Opportunity number (OptyNumber). For more information about path parameters of a resource, see All REST Endpoints.
Get Your Record Using Finders
An easier way to find a specific record is by querying, using the finders and finder variables. Simply use one of the finders and enter the criterion in the finder variable. Here, let's use the finder MyOpportunitiesFinder, and the finder variable name, to get an opportunity with a specific name (Big Data Analytics Server).
Example URL
Use this resource URL format.
Method: GET
https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/opportunities?finder=MyOpportunitiesFinder;Name=Big
Data Analytics Servers
Check out the Finders section in the Get All method documentation of each resource for more information.
Example Response
Here's an example of the response body in JSON format.
{ "items": [ { "BudgetAvailableDate": null, "BudgetedFlag": false, "PrimaryOrganizationId": 204, "ChampionFlag": false, "CreatedBy": "SALES_ADMIN", "CreationDate": "2018-01-08T12:00:24.972+00:00", "CurrencyCode": "USD", "SalesMethodId": 300100073102472, "SalesStageId": 300100073102473, "CustomerAccountId": null, "DealHorizonCode": null, "DecisionLevelCode": null, "Description": null, "LastUpdateDate": "2018-01-08T12:24:05.310+00:00", "LastUpdatedBy": "SALES_ADMIN", "LastUpdateLogin": "6242B5ED93BE3EC9E0539EBDF20ABB8B", "Name": "Big Data Analytics Servers", "OptyId": 300100125332293, "OptyNumber": "CDRM_93472", "OwnerResourcePartyId": 100010025532672, "PrimaryCompetitorId": null, "KeyContactId": null, "ReasonWonLostCode": null, "RiskLevelCode": null, "StatusCode": "OPEN", "StrategicLevelCode": null, "PrimaryRevenueId": 300100125332294, "TargetPartyId": 300100125332282, "TargetPartyName": "Vision Corporation", "SalesMethod": "Sales Process", "SalesStage": "Stage1", "DescriptionText": "Stage1", "AverageDaysAtStage": null, "MaximumDaysInStage": null, "PhaseCd": "QUALIFICATION", "QuotaFactor": 0, ... }
For more information about finding records, see Manage Collections.
Update Your Record
Now, let's try to update the record we created
earlier. We will identify the record using OptyNumber
and use the PATCH method
to update the record.
Example Request
Use this resource URL format.
Method: PUT
https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/opportunities/CDRM_93472
You can update a record by specifying the fields you wish to add in a request body. Here is the request body to update the sales stage of the Opportunity.
Example Request Body
Here's an example of the request body in JSON format.
{ "SalesStage": "Stage2", "DescriptionText": "The Opportunity is in the discovery stage." }
Example Response
Here's an example of the response body in JSON format.
{ "BudgetAvailableDate": null, "BudgetedFlag": false, "PrimaryOrganizationId": 204, "ChampionFlag": false, "CreatedBy": "SALES_ADMIN", "CreationDate": "2018-01-08T12:00:24.972+00:00", "CurrencyCode": "USD", "SalesMethodId": 300100073102472, "SalesStageId": 300100073102473, "CustomerAccountId": null, "DealHorizonCode": null, "DecisionLevelCode": null, "Description": null, "LastUpdateDate": "2018-01-16T15:03:59.677+00:00", "LastUpdatedBy": "SALES_ADMIN", "LastUpdateLogin": "62E62B8DB84D16B5E0539EBDF20A5B9D", "Name": "Big Data Analytics Servers", "OptyId": 300100125332293, "OptyNumber": "CDRM_93472", "OwnerResourcePartyId": 100010025532672, "PrimaryCompetitorId": null, "KeyContactId": null, "ReasonWonLostCode": null, "RiskLevelCode": null, "StatusCode": "OPEN", "StrategicLevelCode": null, "PrimaryRevenueId": 300100125332294, "TargetPartyId": 300100125332282, "TargetPartyName": "Vision Corporation", "SalesMethod": "Sales Process", "SalesStage": "Stage2", "DescriptionText": "The Opportunity is in the discovery stage.", "AverageDaysAtStage": null, "MaximumDaysInStage": null, "PhaseCd": "QUALIFICATION", "QuotaFactor": 0, ... }
To verify if the record is updated, simply get the record as we did in the previous sections.
Congratulations! You've successfully created, updated, and verified a record using Oracle REST APIs.