3

Import SharePoint Online List Items to SAP Analytics Cloud via OData Service (Cl...

 1 year ago
source link: https://blogs.sap.com/2023/03/01/import-sharepoint-online-list-items-to-sap-analytics-cloud-via-odata-service-cloud-solution-without-open-connectors/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Context

With the increasing demands of the SAC users who want to connect to SharePoint List for data visualization and data analysis, I figured out a solution for SAC import connectivity against SharePoint Online List items via BTP Cloud Integration. To achieve it, I deployed an OData API Artifact to retrieve items from SharePoint List without Open Connectors and map entity framework. Compare to the method with Open Connectors, it simplified workflows and we don’t need to configure EDMX or XSD files manually. This blog is to provide End to End connectivity guidance from SharePoint List Add-in Registration to SAC Connection Set up through SAP Integration Suite. Currently, we are not able to use the OAuth2 Client Credentials authentication method directly in SAC against SharePoint Online List as there is one more key-value pair (resource: 00000003-0000-0ff1-ce00-000000000000/<yourSharePointDomain>@TenantID) is required by SharePoint Online when getting the access_token and SAC didn’t provide a place to input this value in the connection dialog. Hence, the below method can be treated as a workaround without modifying the SharePoint OAuth issuer.

Table of Contents

  1. Register SharePoint Add-in
  2. Assign Permission to Add-in
  3. Obtain ClientID@TenantID
  4. Use Postman to Get/Test Access Token and Credentials
  5. Create OAuth2 credentials in Cloud Integration Suite
  6. Create an OData API artifact in a Package
  7. Bind Data Source
  8. Configure OData Receiver
  9. Configure Message Mapping
  10. Deploy OData API
  11. Create Instance and Credentials
  12. Test Deployed OData API in Postman
  13. Create/Test OData Service Connection in SAC

Preparation:

1. Register SharePoint Add-in

  1. Go to https://<yourSharePointDomain>/sites/205434/_layouts/15/appregnew.aspx
  2. Click “Generate” for both Client id and Client Secret
  3. Give a friendly name
  4. Add Domain and Redirect URI
  5. Click “Create” and note down the information

    Client Id:            5d57…8bac

    Client Secret:    bbc7…TTA=

    Title:      WuTestList2App

    App Domain:      localhost

    Redirect URI:      https://localhost

2. Assign Permission to Add-in

  1. Go to https://<yourSharePointDomain>/sites/205434/_layouts/15/appinv.aspx
  2. Copy Client Id into the App id filed
  3. Click “Lookup”
  4. Copy below XML to Permission Request XML. Please also refer to learn.microsoft.com “Table 2. SharePoint add-in permission scope URIs and available rights” And narrow down the permission according to the organization’s security policy. In this example, I will copy all of them to provide insights into how it impacts permissions. 
  5. <AppPermissionRequests AllowAppOnlyPolicy="true">
    
      <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web/list"
        Right="FullControl" />
      <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web/list" Right="Manage" />
      <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web/list" Right="Read" />
      <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web/list" Right="Write" />
    
      <AppPermissionRequest Scope="https://sharepoint/content/tenant" Right="FullControl" />
      <AppPermissionRequest Scope="https://sharepoint/content/tenant" Right="Manage" />
      <AppPermissionRequest Scope="https://sharepoint/content/tenant" Right="Read" />
      <AppPermissionRequest Scope="https://sharepoint/content/tenant" Right="Write" />
    
      <AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="FullControl" />
      <AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="Manage" />
      <AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="Read" />
      <AppPermissionRequest Scope="http://sharepoint/content/sitecollection" Right="Write" />
    
      <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="FullControl" />
      <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="Manage" />
      <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="Read" />
      <AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="Write" />
    
    </AppPermissionRequests>
    
  6. Click “Create”
  7. Select the target SharePoint List from the drop-down list
    Trust-Add-in-App-in-SharePoint.png
  8. Click ”Trust it”

3. Obtain ClientID@TenantID

  1. Go to Site Setting
    SharePoint-Site-Setting-1.png
  2. Select “Site app permission” as below
    SharePoint-App-Permssion-1.png
  3. Find the App and Note down the Clientid@Tenantid (we will use it later). Clientid@Tenantid is
    5d57…8bac@42f7…1af7
    Add-in-App-Information-2.png

4. Use Postman to Get/Test Access Token and Credentials

Please also refer to code2care.org “How to access SharePoint Online data using Postman-REST API and Bearer token

  1. POST https://accounts.accesscontrol.windows.net/[Tenant ID]/tokens/OAuth/2  ([Tenant ID] = Tenantid obtained in step 3-3)
    Add Request Header Content-Type:application/x-www-form-urlencoded
    Add Request Body

    Select: x-www-form-urlencoded

    grant_type:client_credentials

    client_id:Clientid@Tenantid (obtained in step 3-3)

    client_secret: Client Secret (obtained in step 1-5)

    resource: 00000003-0000-0ff1-ce00-000000000000/<yourSharePointDomain>@Tenantid

    Example

    grant_type:client_credentials

    client_id:5d57…8bac@42f7…1af7

    client_secret:bbc7…TTA=

    resource:00000003-0000-0ff1-ce00-000000000000/<yourSharePointDomain>@42f7…1af7

    Postman-get-token.png
  2. Click “Send”
  3. Copy access_token from the response body
    Get-Access-Token-from-Response-Body.png
  4. GET http://<yourSharePointDomain>/sites/205434/_api/web/lists/GetByTitle(‘WuTestList2’)/items
    Add Request Headers

    Authorization:Bearer (paste above access_token)

    Accept:application/json;odata=verbose

If it success, it will return the whole list items with metadata

ListItems-response-body.png

5. Create OAuth2 credentials in Cloud Integration Suite

  1. Navigate to Security Material
    Manage-Security-Material.png
  2. Click “Create” then select “OAuth2 Client Credentials”
    OAuth-Client-Credentials.png
  3. Give a name, then Input the exact same credentials when getting access_token in Postman
    OAuth-Client-Credentials-info.png
  4. Click “Deploy”

6. Create an OData API artifact in a Package

  1. Click “Edit” -> Select “OData API”
    OData-API-creation.png
  2. Select “Create Using Wizard” and give a meaningful name.
    Create-from-Wizard.png
  3. Then Click “Create”
  4. Click “Eidt” -> Click “Import Model Wizard”
    Import-file-to-wizard.png
  5. Select “ODATA”, then import prepared EDMX file
    import-edmx-file.png
  6. Only Select the target list with the target properties
    Select-Structure.png
  7. We can leave the Review and Finish EDMX Structure as default
    Review-EDMX-Strucure.png
  8. Click “Finish” then Click “Save”

7. Bind Data Source

  1. Select the ODATA as Data Source and lick on “link” button
    Bind-SharePoint-data-source.png
  2. Leave the “Upload OData Model” as default because we have uploaded in the beginning and don’t need to change it, then select the Entity Sets from the list. Then put the data service end point https://<yourSharePointDomain>/sites/205434/_vti_bin/listdata.svc/
    Bind-SharePoint-data-source-info-1.png
  3. Click “OK” then Click “Save”

8. Configure OData Receiver

Configure-OData-Receiver.png
  1. Select “OData Receiver”. In Connection Tab, change the Authentication to OAuth2 client credentials and input credentials name: WuTestList2Credentials (we created in step 5-3 for getting the access_token)
    Configure-OData-Receiver-2.png
  2. Go to Processing Tab, change Content Type to JSON.
  3. Leave the rest settings as default

9. Configure Message Mapping

  1. Click on the Message Mapping component, then navigate to Processing Tab
  2. Click on the default mapping link
    Configure-Message-Mapping-1.png
  3. Leave the Source and Target as default (don’t change the file here), then map the Parent node and child nodes.
    Message-Mapping-1.png
  4. Click “Ok”

10. Deploy OData API

  1. Navigate to the below interface and save the setting. Then click “Deploy”
    Deploy-OData-API.png
  2. Go to the Manage Integration Content Manage-Integration-Content.png
  3. Refresh the status, then we will get the Deployed OData API endpoint.
  4. Copy WuTestList2OData EndPoint:
Deployed-OData-API-URL.png

11. Create Instance and Credentials

  1. Go to the subaccount where we create the OData API
  2. Navigate to Instance and Subscriptions
  3. Click “Create” on the top right corner
  4. Input information as below
    Create-Instance-1-1.png
  5. Click “Next”, leave the information as default
    Create-Instance-2.png
  6. Click “Next” to preview information
  7. Create-Instance-3.png
  8. Click “Create”
  9. Then we will see the Instance was created and we will create a service key within this instance
    Create-Service-Key-1.png
  10. Click “Create Service Key” and give a meaningful name in the dialog.
    Create-Service-Key-info.png
  11. Leave the rest of the setting as default then click “Create”. Then we will see the Service key in as the below screen. Click “…” to view the credentials in this key
    Prepare-for-secret-1.png
  12. Then we see all credentials in the dialog. Note down the clientid and clientsecret. We will use them in Postman and SAC. And I will call them as Instance-clientid and instance-clientsecret in the following steps to avoid mistaking with SharePoint add-in client id and client secret
    Credentials-info.png

12. Test Deployed OData API in Postman

  1. Use deloyed OData API URL in Postman. GET https://…/odata/SAP/WUTESTLIST2ODATA;v=1/$metadata
  2. For Authorization, choose “Basic Auth” and input the credentials obtained from step 11-12
  3. Copy EntitySet name from <EntitySet Name=”WuTestList2ItemSet” EntityType=”S1.WuTestList2Item”/> in Response body
    So my EntitySet name is WuTestList2ItemSet
    Auth-method-in-Postman-1.png
  4. Change GET URL to https://…/odata/SAP/WUTESTLIST2ODATA;v=1/WuTestList2ItemSet
    At the same time, we can update the list items in SharePoint and test the updates in response body
    SharePoint-List-test-in-Postman.png

13. Create/Test OData Service Connection in SAC

  1. Select OData Services from the connection area in SAC. Give a meaningful name and input information in below table. And click “OK”
    Data Service URL Deployed OData API URL
    https://…/gw/odata/SAP/WUTESTLIST2ODATA;v=1
    Authentication Type Basic Authentication
    User Name Instance-clientid
    Password Instance-clientsecret
    Connection-in-SAC.png
  2. Navigate to Model and select the newly created SharePoint list connection from the drop-down list
    Create-a-Model.png
  3. Select the EntitySet
    Select-Entity-Set.png
  4. Build OData Service Query and click “Create”.
    Build-a-query.png
  5. If the connection and OData API integration flow are correct. Then data is imported into SAC successfully. We can also schedule the import activities as the screenshot below.
    Data-Imported.png
    Schedule-Data-Import.png

Summary

As described in the context, this solution fits SharePoint Online and it is a one-time configuration. But please note that


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK