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 Public Sector Compliance and Regulation services, 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 employee records

curl  -u username:password \
-X GET https://servername.fa.us2.oraclecloud.com/hcmRestApi/resources/<version>/emps \
-H 'content-type: application/vnd.oracle.adf.resourceitem+json' 

Use PATCH to update a work order

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

Use POST to create an account

curl  -u username:password \
 -X POST -d @request_payload.json https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/<version>/accounts \
 -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 account.

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

{
   "PartyId" : 999997549785817,
   "PartyNumber" : "CDRM_262783",
   "SourceSystem" : null,
   "SourceSystemReferenceValue" : null,
   "OrganizationName" : "Softgear",
   "UniqueNameSuffix" : "(US)",
   "PartyUniqueName" : "Softgear_1023	(US)",
   "Type" : "ZCA_CUSTOMER",
   "OwnerPartyId" : null,
   "OwnerPartyNumber" : null,
   "OwnerEmailAddress" : null,
   "OwnerName" : null,
   ...  
}

POST: Create a new role.

Request URL: https://servername.fa.us2.oraclecloud.com/hcmRestApi/resources/<version>/emps/{id}/child/roles

{
  "RoleName": "PER_LINE_MANAGER_ABSTRACT"
}

PATCH: Update the work email of an employee.

Request URL: https://servername.fa.us2.oraclecloud.com/hcmRestApi/resources/<version>/emps/{id}

{
  "WorkEmail": "josh.watson@ymail.com"
}

With an understanding of how your REST API client works, you can next review for a sample workflow that demonstrates how to create, update, verify, and retrieve information about a record.