SAP-samples / btp-developer-guide-cap

SAP BTP Developer’s Guide offers developer guidance to software developers on how to implement business applications using SAP Cloud Application Programming Model on SAP BTP Cloud Foundry and SAP BTP Kyma Runtime following the best practices.
Apache License 2.0
37 stars 22 forks source link

Remote Service Mock - Working fine with local mock server when testing locally but not working after deploying to BTP #103

Closed sammok83 closed 9 months ago

sammok83 commented 9 months ago

I've done all all the steps and pre-requisites of https://github.com/SAP-samples/btp-developer-guide-cap/blob/main/documentation/remote-service/remote-service-mock-cf.md

Tested Locally with the mock server and everything is working fine. However after deploying it to CF on BTP, the connection to the external service (mock server) did not work. This when querying the Customer dropdown: image

Error as below: **--batch_id-1708430817172-490 content-type: application/http content-transfer-encoding: binary

HTTP/1.1 502 undefined odata-version: 4.0 content-type: application/json;odata.metadata=minimal;IEEE754Compatible=true

{"error":{"code":"502","message":"Error during request to remote service: \nRequest failed with status code 404"}} --batch_id-1708430817172-490--**

Mock Server destination define and working fine: image

Querying is working fine too with the URL defined in the destination: image

Credentials defined in package.json: image

navinkrishnan commented 9 months ago

Hi @sammok83 Please change the path in credential configuration in package.json.

"API_BUSINESS_PARTNER": {
                "kind": "odata-v2",
                "model": "srv/external/API_BUSINESS_PARTNER",
                "[production]": {
                    "credentials": {
                        "destination": "incidents-api-access",
                        "path": "/odata/v2/api-business-partner"
                    }
                }
            }

We have recently migrated the mock server to cap-js-community/odata-v2-adapter which requires this new path. Documents will be updated soon.

sammok83 commented 9 months ago

Thanks works now