Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Oracle Cloud Rest API to ODATA #129

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions examples/Oracle Cloud Rest API to ODATA
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!--
This policy converts the results of an oracle cloud rest api to an 'odata-like format'.
The items element is renamed to value.
An '@odata.nextlink' is generated using the count and offset received from oracle and added to the output.
With these updates, the oracle api can be called from azure logic apps and PowerAutomate
with the paging option enabled and Logicapps will iteate through all the pages for you
-->
<policies>
<inbound>
<base />
</inbound>
<backend>
<forward-request timeout="240" />
</backend>
<outbound>
<base />
<set-body>@{
var asciiAt=(char)64;
var nextLinkFieldName=asciiAt+"odata.nextlink";
var response = context.Response.Body.As<JObject>(preserveContent: true);
var hasMore=response.GetValue("hasMore").Value<bool>();
var items=response.GetValue("items");
response.Add("value",items);
response.Remove("items");
if(hasMore){
var count=response.GetValue("count").Value<int>();
var limit=response.GetValue("limit").Value<int>();
var offset=response.GetValue("offset").Value<int>();
var nextOffset=offset+count;
var nextLink=$"https://bteapim.azure-api.net/oracle-clone/fscmRestApi/resources/latest/receivablesInvoices?offset={nextOffset}&limit={limit}";
response.Add(nextLinkFieldName,nextLink);
}
return response.ToString();

}</set-body>
</outbound>
<on-error>
<base />
</on-error>
</policies>