cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Business Application Studio - REST API Integration

0 Kudos

Hello Experts,

I was exploring SAP Business Application Studio and trying to consume REST based webservice (no OData) in SAPUI5 /Fiori application. But while trying to invoke the service I am getting 404 Not Found Error,

Followed below steps,

1. Created the required destination in SAP BTP, as shown below,

2. Create SAP Fiori/UI5 Application,
- Create Basic MTA Project
- Create Managed Application Router
- Create SAPUI5 Freestyle App

3. Added the below configuration in xs-app.json,

{"authenticationType": "none","csrfProtection": false,"source": "^/FMM_RMS/(.*)$","destination": "FMM_RMS","target": "$1"}

4. REST API to consume,

/hr-tech/visibility-per/getVisibilityByEmployeeId?employeeId=FMM0001&date=2021-05-13

5. AJAX call in controller.js

$.ajax({// url:"/bd91c945-3a6a-48c5-9237-14d64031ba13.BP.nstestdemo-1.0.0/FMM_RMS/hr-tech/visibility-per/getVisibilityByEmployeeId?employeeId=FMM0001&date=2021-05-13",
    url:"FMM_RMS/hr-tech/visibility-per/getVisibilityByEmployeeId?employeeId=FMM0001&date=2021-05-13",type:"GET",
    async: true,headers:{accept:'application/json',
        contentType:'application/json'},
    success:function(data){
        debugger;},
    error:function(oError){
        debugger;}});

No other file has been modified.

Please let me know which configuration/code I am missing.

Note: I was able to consume OData service seamlessly.

Regards,

Sharique

Margot
Product and Topic Expert
Product and Topic Expert
0 Kudos

Can you provide some more details on from where you try to consume your REST-based web service?

To me it seems that your destination configuration is not correct which leads to this error.

0 Kudos

Hi Margot,

Thanks for your reply.

I am trying to consume this service in Cloud Foundry Environment.

I tried validating the destination in BAS using curl, and it seems to be working fine,

curl -v -i "FMM_RMS.dest/hr-tech/visibility-per/getVisibilityByEmployeeId?employeeId=FMM0001&date=2021-05-13"

Regards,

Sharique

yuval_morad
Employee
Employee
0 Kudos

Please share your manifest.json

Also the target runtime is it CF or ABAP used as deployment target

Hi Yuval,

Thanks for your reply.

Target runtime is CF.

Attached manifest.json below,

{
    "_version": "1.32.0",
    "sap.app": {
        "id": "ns.testdemo",
        "type": "application",
        "i18n": "i18n/i18n.properties",
        "applicationVersion": {
            "version": "1.0.0"
        },
        "title": "{{appTitle}}",
        "description": "{{appDescription}}",
        "resources": "resources.json",
        "ach": "ach"
    },
    "sap.ui": {
        "technology": "UI5",
        "icons": {
            "icon": "sap-icon://task",
            "favIcon": "",
            "phone": "",
            "phone@2": "",
            "tablet": "",
            "tablet@2": ""
        },
        "deviceTypes": {
            "desktop": true,
            "tablet": true,
            "phone": true
        }
    },
    "sap.ui5": {
        "flexEnabled": false,
        "rootView": {
            "viewName": "ns.testdemo.view.View1",
            "type": "XML",
            "async": true,
            "id": "View1"
        },
        "dependencies": {
            "minUI5Version": "1.66.0",
            "libs": {
                "sap.ui.core": {},
                "sap.m": {},
                "sap.ui.layout": {}
            }
        },
        "contentDensities": {
            "compact": true,
            "cozy": true
        },
        "models": {
            "i18n": {
                "type": "sap.ui.model.resource.ResourceModel",
                "settings": {
                    "bundleName": "ns.testdemo.i18n.i18n"
                }
            }
        },
        "resources": {
            "css": [
                {
                    "uri": "css/style.css"
                }
            ]
        },
        "routing": {
            "config": {
                "routerClass": "sap.m.routing.Router",
                "viewType": "XML",
                "async": true,
                "viewPath": "ns.testdemo.view",
                "controlAggregation": "pages",
                "controlId": "app",
                "clearControlAggregation": false
            },
            "routes": [
                {
                    "name": "RouteView1",
                    "pattern": "RouteView1",
                    "target": [
                        "TargetView1"
                    ]
                }
            ],
            "targets": {
                "TargetView1": {
                    "viewType": "XML",
                    "transition": "slide",
                    "clearControlAggregation": false,
                    "viewId": "View1",
                    "viewName": "View1"
                }
            }
        }
    },
    "sap.cloud": {
        "public": true,
        "service": "BP"
    }
}

No changes were done to this file.

Regards,

Sharique

former_member664730
Participant
0 Kudos

Hi Sharique,

I am also facing same issue. could you please share solution if it's resolved.

UdayMS
Participant
0 Kudos

Hi Sharique

Even I have the same requirement and issue. Pls let me know if its resolved

Thanks

Uday

maari
Discoverer
0 Kudos

Hi Sharique, Phani and Uday,

Any of you got the solution for issue. Pls let me know.

Thanks

Maruti

sachinkalpetta
Explorer
0 Kudos

Hi sharique.kamal.nasser ,

I hope you are getting this while you run it from BAS. What command are using to run the app.

Thanks,

Sachin Srambickal

Accepted Solutions (0)

Answers (0)