Work with your REST API Client

Because REST APIs use HTTP methods to send and receive content, you can test REST APIs using any programming language or tool that supports sending and receiving HTTP messages. So, let's first choose a tool for making HTTP requests.

Choosing a REST API Client

You can choose among many REST API clients that interact with Oracle Applications Cloud, such as:
  • A standalone client, such as Postman or Advanced REST Client
  • Your connecting application's client
  • The cURL command-line utility
With a REST API client you can:
  • Test the username, password, and request URL for your REST API account.
  • Perform view and describe actions to learn more about REST resources, attributes, and parameters.
  • Use the collected information to construct and send various types of HTTP requests, such as those to create, update, or delete records.

Using cURL to Send HTTP Requests

In our examples, we use cURL, a popular command-line utility for transferring data using URL syntax, to send requests to REST services. cURL is available in most UNIX, Windows, and Macintosh environments. For details, see Installing the cURL Command-Line Tool on Windows.

The following table describes commonly used cURL options that you can use for REST services.

Option Description

-user

username:password

Specifies the user name and password for server authentication.

-d

Sends the specified data (a JSON request body) to the server. If you begin the data with the @ sign, then @ must be followed by a file name to read the data from.

-H

Specifies an extra HTTP header in the request. To specify multiple headers, precede each header with the -H option.

Examples:
  • Content-Type: Format of request body (for example, with POST)
  • Accept: Format of response body
  • X-Auth-Token: Authentication token

-output

<file>

Writes the output to a file instead of to stdout.

-X

Specifies the request method to use when communicating with the HTTP server. The default method is GET.

The following table shows Oracle Applications Cloud examples of the GET, PATCH, and POST operations using cURL.

Operation cURL Command Example

Use GET to retrieve all opportunities

curl  -u username:password \
-X GET https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/<version>/opportunities \
-H 'Content-Type: application/vnd.oracle.adf.resourceitem+json' 

Use PATCH to update an opportunity

curl -u username:password \
-X PATCH -d @request_payload.json https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/<version>/opportunities/{OptyNumber} \
-H "Content-Type: application/vnd.oracle.adf.resourceitem+json" 

Use POST to create an opportunity

curl  -u username:password \
 -X POST -d @request_payload.json https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/<version>/opportunities \
 -H "Content-Type: application/vnd.oracle.adf.resourceitem+json"

Using REST API Clients to Send HTTP Requests

You can use standalone clients, third-party browser extensions, or add-ons, such as the Advanced REST Client, to send HTTP requests. The following table includes examples of the GET, POST, and PATCH operations using a REST API client.

Operation Response/Payload Example

GET: Get an opportunity.

Request URL: https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/<version>/opportunities/{OptyNumber}

{
  "PrimaryOrganizationId" : 204,
  "CurrencyCode" : "USD",
  "SalesMethodId" : 100000012430001,
  "SalesStageId" : 100000012430007,
  "Name" : "Major Server Upgrade",
  "OptyId" : 300100111705686,
  "OptyNumber" : "CDRM_332708",
  "OwnerResourcePartyId" : 3807,
  "KeyContactId" : 100000016105039,
  "PrimaryRevenueId" : 300100111705687,
  "SalesMethod" : "Standard Sales Process",
  "SalesStage" : "01 - Qualification",
  "DescriptionText" : "Looking for the Right Contacts, Characteristics, Determining the Need, Budget and Sponsor",
  "AverageDaysAtStage" : 30,
  "MaximumDaysInStage" : 800,
  "PhaseCd" : "QUALIFICATION-DISCOVERY",
  "ForecastOverrideCode" : "CRITERIA",
  "SalesChannelCd" : "ZPM_DIRECT_CHANNEL_TYPES",
...
}

POST: Create a new opportunity.

Request URL: https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/<version>/opportunities

{
BudgetAvailableDate: null
BudgetedFlag: false
PrimaryOrganizationId: 204
ChampionFlag: false
CreatedBy: "SALES_ADMIN"
CreationDate: "2015-06-04T03:08:27-07:00"
CurrencyCode: "USD"
SalesMethodId: 100000012430001
SalesStageId: 100000012430007
Name: "Major Application Upgrade"
OptyId: 300100111705686
OptyNumber: "CDRM_332708"
OwnerResourcePartyId: 3807
StatusCode: "OPEN"
PrimaryRevenueId: 300100111705687
SalesMethod: "Standard Sales Process"
SalesStage: "01 - Qualification"
DescriptionText: "Looking for the Right Contacts, Characteristics, Determining the Need, Budget and Sponsor"
AverageDaysAtStage: 30
MaximumDaysInStage: 800
PhaseCd: "QUALIFICATION-DISCOVERY"
QuotaFactor: 3
RcmndWinProb: 0
StageStatusCd: "OPEN"
StgOrder: 1
EffectiveDate: "2015-06-24"
Revenue: 0
WinProb: 0
PartyName1: "Charles Taylor"
DownsideAmount: 0
UpsideAmount: 0
EmailAddress: "firstname_lastname@orcl.com"
ExpectAmount: 0
ForecastOverrideCode: "CRITERIA"
SalesChannelCd: "ZPM_DIRECT_CHANNEL_TYPES"
...
}

PATCH: Update the contact of an opportunity.

Request URL: https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/<version>/opportunities/{Optynumber}/child/OpportunityContact/{OptyConId}

{
OptyConId: 300100092629555,
CreatedBy: "MHoope",
ContactedFlg: "N",
CreationDate: "2016-11-17T05:54:14-08:00",
OptyId: 300100092516122,
PERPartyId: 100000016934214,
PrimaryFlg: "N",
PartyName: "Matt Baird",
OptyConId: 300100092629899,
EmailAddress: "mbaird@oracle.com",
ContactPointId: 300100026717170,
FormattedAddress: "South Avenue,MANHATTAN, NY 10005",
FormattedPhoneNumber: "+1 (640) 345-3456 x6567",
DoNotContactFlag: false,
ContactPartyNumber: 100000016934213,
RoleCd: "SECONDARY_DECISION_MAKER",
...
}