Invoking SaaS REST API from an Autonomous Database


Oracle SaaS applications provide, among others, a comprehensive set of REST APIs. Oracle Autonomous Database and the entire family of Oracle database product offerings provide rich and easy-to-invoke API mechanisms. Let’s see an example:

Creating a sales order

With a simple PL/SQL block of code we are showing down here how easy is to create a sales order.

declare
   result clob;
   payload CLOB;
begin
   payload := '{"SourceTransactionNumber": 333,"SourceTransactionSystem": "OPS","SourceTransactionId": 333,"BusinessUnitName": "Sxcxrxtxs Dxrxct Xspxñx S.X.U","BuyingPartyName": "ES_NEW","TransactionType": "SBN WO","RequestedShipDate": "2020-03-01T00:00:00+00:00","PaymentTerms": "30 Net","TransactionalCurrencyName": "Euro","RequestingBusinessUnitName": "Sxcxrxtxs Dxrxct Xspxñx S.X.U","FreezePriceFlag": false,"FreezeShippingChargeFlag": false,"FreezeTaxFlag": false,"SubmittedFlag": true,"SourceTransactionRevisionNumber": 1,"lines": [{"SourceTransactionLineId": "1","SourceTransactionLineNumber": "1","SourceTransactionScheduleId": "1","SourceScheduleNumber": "1","TransactionCategoryCode": "ORDER","TransactionLineType": "Buy","ProductNumber": "2227","OrderedQuantity": 1,"OrderedUOM": "Each"}]}';

   apex_web_service.g_request_headers(1).name := 'Content-Type';
   apex_web_service.g_request_headers(1).value := 'application/json';

   result := apex_web_service.make_rest_request(
   p_url => 'https://xyjk-lmno.fx.xm2.xrxclxclxxd.cxm/fscmRestApi/resources/11.13.18.05/salesOrdersForOrderHub',
p_http_method => 'POST', p_username => 'felipitotacatun', p_password => 'yosigo', p_body => payload);

   dbms_output.put_line('result: ' || result );
end;

As you can see the procedure completes successfully:

And the new sales order gets created:

Hope it helps! 🙂

2 Comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.