cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with Specifying Data Source URI

xenopen
Explorer
0 Kudos
141

In the manifest.json of the SAPUI5 application, when the URI of the OData data source is specified with a leading "/", it cannot connect to the data source when deployed to the HTML5 repository of SAP BTP. Therefore, all leading "/" in the URI of the manifest.json were removed.

The necessity of removing "/" was provided in the following inquiry.

Case Management Dashboard - SAP for Me

Removing the "/" improved the issue on SAP BTP, but now there is a problem where the URI to the backend does not work as expected during hybrid development in BAS.

Approuter's xs-app.json

{
  "authenticationMethod": "route",
  "routes": [
    {
      "source": "^/app/(.*)$",
      "target": "/app/$1",
      "destination": "node_main-app-srv",
      "csrfProtection": true,
      "cacheControl": "no-cache, no-store, must-revalidate"
    },
    {
      "source": "^/(.*)$",
      "target": "$1",
      "destination": "node_main-app-srv",
      "csrfProtection": true,
      "authenticationType": "xsuaa"
    }
  ],
  "logout": {
    "logoutEndpoint": "/logout"
  }
}

Approuter's default-env.json

{
  "CDS_PORT": 4004,
  "CF_NODEJS_LOGGING_LEVEL": "debug",
  "destinations": [
    {
      "Name": "node_main-app-srv",
      "Authentication": "NoAuthentication",
      "ProxyType": "Internet",
      "Type": "HTTP",
      "URL": "<http://localhost:4004/>",
      "forwardAuthToken": true
    }
  ]
}

Manifest.json

{
  "_version": "1.60.0",
  "sap.app": {
    "id": "com.gsl.app.forms",
    "type": "application",
    "i18n": "i18n/i18n.properties",
    "applicationVersion": {
      "version": "${version}"
    },
    "title": "{{appTitle}}",
    "description": "{{appDescription}}",
    "resources": "resources.json",
    "sourceTemplate": {
      "id": "@sap/generator-fiori:lrop",
      "version": "1.10.4",
      "toolsId": "39b06494-5076-48e2-8f2c-fcce8a4f2c5d"
    },
    "dataSources": {
      "mainService": {
        "uri": "odata/v4/forms/",
        "type": "OData",
        "settings": {
          "annotations": [],
          "localUri": "localService/metadata.xml",
          "odataVersion": "4.0"
        }
      }
    },
    "crossNavigation": {
      "inbounds": {
        "com-gsl-app-forms-inbound": {
          "signature": {
            "parameters": {},
            "additionalParameters": "allowed"
          },
          "semanticObject": "forms",
          "action": "list",
          "title": "{{flpTitle}}",
          "subTitle": "{{flpSubtitle}}",
          "info": "{{flpInfo}}",
          "icon": "sap-icon://survey"
        }
      }
    }
  },
  "sap.ui": {
    "technology": "UI5",
    "icons": {
      "icon": "",
      "favIcon": "",
      "phone": "",
      "phone@2": "",
      "tablet": "",
      "tablet@2": ""
    },
    "deviceTypes": {
      "desktop": true,
      "tablet": true,
      "phone": true
    }
  },
  "sap.ui5": {
    "flexEnabled": true,
    "dependencies": {
      "minUI5Version": "1.120.1",
      "libs": {
        "sap.m": {},
        "sap.ui.core": {},
        "sap.ushell": {},
        "sap.fe.templates": {},
        "sap.fe.macros": {},
        "sap.f": {}
      }
    },
    "contentDensities": {
      "compact": true,
      "cozy": true
    },
    "models": {
      "i18n": {
        "type": "sap.ui.model.resource.ResourceModel",
        "settings": {
          "bundleName": "com.gsl.app.forms.i18n.i18n"
        }
      },
      "": {
        "dataSource": "mainService",
        "preload": true,
        "settings": {
          "synchronizationMode": "None",
          "operationMode": "Server",
          "autoExpandSelect": true,
          "earlyRequests": true
        }
      },
      "@i18n": {
        "type": "sap.ui.model.resource.ResourceModel",
        "uri": "i18n/i18n.properties"
      }
    },
    "resources": {
      "css": [
        {
          "uri": "css/style.css"
        }
      ]
    },
    "routing": {
      "config": {
        "flexibleColumnLayout": {
          "defaultTwoColumnLayoutType": "TwoColumnsMidExpanded",
          "defaultThreeColumnLayoutType": "ThreeColumnsEndExpanded"
        },
        "routerClass": "sap.f.routing.Router"
      },
      "routes": [
        {
          "pattern": ":?query:",
          "name": "QuestionnairesList",
          "target": ["QuestionnairesList"]
        },
        {
          "name": "EntryForm",
          "pattern": "Questionnaires({key}):?query:",
          "target": ["QuestionnairesList", "EntryForm"]
        }
      ],
      "targets": {
        "QuestionnairesList": {
          "type": "Component",
          "id": "QuestionnairesList",
          "name": "sap.fe.templates.ListReport",
          "options": {
            "settings": {
              "entitySet": "Questionnaires",
              "controlConfiguration": {
                "@com.sap.vocabularies.UI.v1.SelectionFields": {
                  "useSemanticDateRange": true,
                  "showClearButton": true
                }
              },
              "variantManagement": "Page",
              "initialLoad": true,
              "navigation": {
                "Questionnaires": {
                  "detail": {
                    "route": "EntryForm"
                  }
                }
              }
            }
          },
          "controlAggregation": "beginColumnPages"
        },
        "EntryForm": {
          "type": "Component",
          "id": "EntryForm",
          "name": "sap.fe.core.fpm",
          "options": {
            "settings": {
              "viewName": "com.gsl.app.forms.ext.entry.Entry",
              "contextPath": "/Questionnaires"
            }
          },
          "controlAggregation": "midColumnPages"
        }
      }
    },
    "rootView": {
      "viewName": "sap.fe.templates.RootContainer.view.Fcl",
      "type": "XML",
      "async": true,
      "id": "appRootView"
    },
    "extends": {
      "extensions": {
        "sap.ui.controllerExtensions": {}
      }
    }
  },
  "sap.fiori": {
    "registrationIds": [],
    "archeType": "transactional"
  },
  "sap.cloud": {
    "public": true,
    "service": "gasp_main.service"
  }
}

Logs from Approuter when the URI of the data source in manifest.json is set to "odata/v4/forms/":

Incoming request to AppRouter. Path: /com.gsl.app.forms/odata/v4/forms/

Request to backend. Rewritten URL: <http://localhost:4004/com.gsl.app.forms/odata/v4/forms/>

Request to backend. Destination details: name: node_main-app-srv url: <http://localhost:4004/>

Logs from Approuter when the URI of the data source in manifest.json is set to "/odata/v4/forms/":

Incoming request to AppRouter. Path: /odata/v4/forms/

Request to backend. Rewritten URL: <http://localhost:4004/odata/v4/forms/>

Request to backend. Destination details: name: node_main-app-srv url: <http://localhost:4004/>

Both logs are accessed at https://port5000-workspaces-ws-9g7tp.jp10.applicationstudio.cloud.sap/com.gsl.app.forms/index.html.

View Entire Topic
Former Member
0 Kudos

You should not remove the leading '/' from the url in the source code. It is removed, by fiori tools, during build if you deploy to html5-repository. After build, the file in dist folder should not have the leading '/'. The content in dist folder is what is deployed to html5-repo. The content in webapps folder is used during development; the file in webapps folder needs '/' in data source url for the development tools to work correctly proxy the requests. 

Generate Deployment Configuration Cloud Foundry | SAP Help Portal