Work with Your REST 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.

Note:

Oracle REST APIs aren't OData (Open Data Protocol) compliant.

Considerations for Choosing a REST Client

You can choose among many clients that interact with Fusion Applications, such as:

You can use the client to do the following tasks:

  • 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.

How You Send HTTP Requests Using cURL

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 examples of the GET, PATCH, and POST operations using cURL.

Operation cURL Command Example

Use GET to retrieve all the announcements.

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

Use PATCH to update an announcement.

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

Use POST to create an announcement.

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

How You Send HTTP Requests Using Clients

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 client.

Operation Response/Payload Example

GET: Get an announcement.

Request URL: https://servername.fa.us2.oraclecloud.com/fscmRestApi/resources/<version>/announcements/{AnnouncementId}

{
"AnnouncementId": "300100090149733",
"CategoryCode": "OF",
"CreatedBy": "SEED_DATA_FROM_VERTICAL",
"CreationDate": "2017-05-18T08:51:04.001+00:00",
"ExpireDate": "2017-05-19T00:00:00+00:00",
"ExpiryDaysFlag": null,
"LastUpdateDate": "2017-05-18T08:51:07.609+00:00",
"LastUpdateLogin": "4FC58160B86257BCE0539D06F10A598C",
"LastUpdatedBy": "SEED_DATA_FROM_VERTICAL",
"ObjectVersionNumber": 1,
"StartDate": "2017-05-18T00:00:00+00:00",
"Subject": "meeting at 4pm ",
"Description": "meeting at 4pm",
   ...  
}

POST: Create an announcement.

Request URL: https://servername.fa.us2.oraclecloud.com/fscmRestApi/resources/<version>/announcements

{
"Subject": "meeting at 4pm",
"CategoryCode": "OF",
"StartDate": "2017-05-09",
"ExpireDate": "2017-05-10",
"Description": "meeting at 4pm"
}

PATCH: Update the description of an announcement.

Request URL: https://servername.fa.us2.oraclecloud.com/fscmRestApi/resources/<version>/announcements/{AnnouncementId}

{
  "Description": "meeting at 4pm"
}

With an understanding of how your client works, you can next review how to Add a Role to a User for a sample workflow that demonstrates how to retrieve and update information about a record.