Friday, 21 June 2024

SAP Cloud Integration Manage Artifacts Of Design Time

Introduction:

In cloud integration, the processes of creating, deleting, or modifying a flow are done manually by entering the package. I will show how to perform these processes through the CPI link. The aim of this blog is to highlight the flexible structure of CPI.

Required:

◉ SAP BTP and Integration Suite 

Cloud Integration Steps:

To demonstrate how all the processes work, I have covered them all in a single flow. This includes flow deletion, updating, creation, and the information we can retrieve related to the flow.

For a more straightforward architecture, I utilized process calls. Based on the type of request, process calls will be executed via the router.

The API we will use: https://{Account Short Name}-tmn.{SSL Host}.{region}.hana.ondemand.com/api/v1/IntegrationDesigntimeArtifacts

1 - The overall view of the flow:

SAP Cloud Integration Manage Artifacts Of Design Time

Local Process 1 : POST

SAP Cloud Integration Manage Artifacts Of Design Time

Local Process 2 : PUT

SAP Cloud Integration Manage Artifacts Of Design Time

Local Process 3: GET

SAP Cloud Integration Manage Artifacts Of Design Time

Local Process 4: DELETE

SAP Cloud Integration Manage Artifacts Of Design Time

The reason we separate with the router is that some processes require mapping, while others do not.

2 - CM_Headers&Properties:

Our service works with a CSRF token, so we need to obtain the token first. In the initial content modifier, we store the request headers of the service.

Headers:

SAP Cloud Integration Manage Artifacts Of Design Time

Properties:

We are storing parameters like Name, Id, PackageId, and Version in properties because we will use them in our services.

SAP Cloud Integration Manage Artifacts Of Design Time

3 - HTTP Fetch Token:

A defined user must access CPI as an authorized user. After defining security materials, credentials are provided in the flow.

SAP Cloud Integration Manage Artifacts Of Design Time

4 - CM_SetHeaders:

The service's response headers:

Content-type: application/atom+xml;type=entry;charset=utf-8

fetch-cookie : ${header.set-cookie}

cookie : ${header.fetch-cookie.replace("[","").replace("]","").replace("; path=/; secure; HttpOnly","").replace("path=/, ","")}

I defined "fetch cookie" to avoid getting a forbidden error due to cookies in the service.


SAP Cloud Integration Manage Artifacts Of Design Time

5-Router:

SAP Cloud Integration Manage Artifacts Of Design Time

6 - First Method : POST 

Since our goal is to create a flow using the POST method, here is the body we will send:

{
"Name": "string",
"Id": "string",
"PackageId": "Id of Package"
}

Message Mapping:

We stored the sent fields in properties in the content modifier. In the mapping, we will retrieve them from the properties.

SAP Cloud Integration Manage Artifacts Of Design Time

OData V2- Connection and Processing:

SAP Cloud Integration Manage Artifacts Of Design Time

SAP Cloud Integration Manage Artifacts Of Design Time

Content Modifier:

SAP Cloud Integration Manage Artifacts Of Design Time

SAP Cloud Integration Manage Artifacts Of Design Time

Let's try it now in Postman.

SAP Cloud Integration Manage Artifacts Of Design Time

Authorization:

CPI Technical User 
 
Body:

<Root>
    <Id>TestFlow</Id>
    <Name>TestFlow</Name>
    <PackageId>Testing</PackageId>
</Root>

SAP Cloud Integration Manage Artifacts Of Design Time

GET METHOD:

We will obtain information about these artifacts by providing the Id and Version details from within the package.

/api/v1/IntegrationDesigntimeArtifacts(Id='${property.Id}',Version='${property.Version}')

SAP Cloud Integration Manage Artifacts Of Design Time

Content Modifier:

SAP Cloud Integration Manage Artifacts Of Design Time

Postman :

<Root>
    <Id>TestFlow</Id>
    <Version>1.0.0</Version>
</Root>

SAP Cloud Integration Manage Artifacts Of Design Time

 PUT METHOD:

    
SAP Cloud Integration Manage Artifacts Of Design Time


SAP Cloud Integration Manage Artifacts Of Design Time

Postman:

Body:

<Root>
    <Name>ChangingNameTestFlow</Name>
    <Id>TestFlow</Id>
    <Version>1.0.0</Version>
</Root>

SAP Cloud Integration Manage Artifacts Of Design Time

SAP Cloud Integration Manage Artifacts Of Design Time

DELETE METHOD:

/api/v1/IntegrationDesigntimeArtifacts(Id='${property.Id}',Version='${property.Version}')

SAP Cloud Integration Manage Artifacts Of Design Time

Content Modifier:

SAP Cloud Integration Manage Artifacts Of Design Time

Postman:

Body:

<Root>
    <Id>TestFlow</Id>
    <Version>1.0.0</Version>
</Root>

SAP Cloud Integration Manage Artifacts Of Design Time

SAP Cloud Integration Manage Artifacts Of Design Time

Additional: A Groovy script exists within the subprocess to catch exceptions. I have embedded it into all local processes. Sometimes, error details don't propagate to the exception subprocess in the main flow, so you can embed them into local processes.

No comments:

Post a Comment