Technology Blog Posts by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
GiuseppeMP
Explorer
758

TL;DR

Hey everyone, I'm a very new developer in the SAP ecosystem and I want to share some stuff.

To consume the SAP Cloud Integration APIs from JS/TS, you must install the SAP Cloud SDK and utilize the generated clients. It is necessary to properly configure tsconfig when using Typescript, which can be challenging as it may not always be compatible with your project.

(Trying to write down a entire client using axios is really painful)

Additionally, these files begin to appear in every project, leading to unnecessary boilerplate in many repositories within SAP projects.

Now you can simply run `npm install ts-sap-cloud-odata-api-v2-client` and start using the generated clients immediately without any stress.

Read more: https://sap.github.io/cloud-sdk/docs/js/getting-started

Process followed: https://sap.github.io/cloud-sdk/docs/js/features/odata/generate-client

Features

I've just generated clients for the https://api.sap.com/package/CloudIntegrationAPI/odata

Before moving forward, please pay attention to this: https://github.com/GiuseppeMP/sap-cloud-integration-odata-api-v2-clients?tab=readme-ov-file#-disclai... 🙏

Install

 

 

 

 

 

npm i ts-sap-cloud-odata-api-v2-client

 

 

 

 

 



Dependencies

 

 

 

 

 

 

npm i -cloud-sdk/connectivity #required
npm i -cloud-sdk/odata-v2 #optional

 

 

 

 

 



Usage

Now you can simply use the generated clients in your code. The entire interface was kept from the SDK, and you can refer to the https://sap.github.io/cloud-sdk/docs/js/getting-started to learn more.

https://sap.github.io/cloud-sdk/docs/js/features/odata/execute-request


Each client is isolated in a module that can be imported using `'ts-sap-cloud-odata-api-v2-client/{APINAME}'`.
This is necessary to avoid conflicts with other modules as they are all generated separately.

Example that how I'm using

 

 

 

 

 

import {messageProcessingLogs, MessageProcessingLogsType } from 'ts-sap-cloud-odata-api-v2-client/MessageProcessingLogs'
import { registerDestination } from '@sap-cloud-sdk/connectivity'

async function example(name: string, url: string) {

await registerDestination(
{
name: name, // choose name
url: url // add url to your tenant
},
);

const basePath = "/api/v1" // change if needed

const requestBuilder = messageProcessingLogs<MessageProcessingLogsType>().messageProcessingLogsApi.requestBuilder().getAll()

const getAll = requestBuilder.setBasePath(basePath).addCustomHeaders({ 'authorization': `Bearer ...` })

return getAll.execute({ destinationName: name })
}

 

 

 

 

 

Show your support

Give a ️ if this project helped you!

If you would like to ask about features, other API clients, report bugs, or seek help, please feel free to create an issue in the GitHub repository.

https://github.com/GiuseppeMP/sap-cloud-integration-odata-api-v2-clients/issues/new

It's a very new repository, I really appreciate feedback and collaborations folks!


See you!

2 Comments
Labels in this area