on 10-06-2021 9:12 PM
I am trying to call external API using BTP Business Studio for SAPUi5 App
1) API first needs to get the bearer Token, I have created destination using Basic Authentication.
In SAPUI5 code
var url = "/oauth/token?grant_type=client_credentials";
var ajaxRequest = {};
ajaxRequest.url = url;
ajaxRequest.method = "GET";
ajaxRequest.headers = header;
ajaxRequest.contentType = true;
ajaxRequest.processData = false;
ajaxRequest.success = successcallback.bind(this);
jQuery.ajax(ajaxRequest);
Bearer Token is getting returned
View1.controller.js:153 {Authorization: 'Bearer eyJhbGciOiJSUzI1NiIsImprdSI6Imh0dHBzOi8vZDF…aIL-ZziUPK1DqXUmApUNEr1n8BiSwDjZfwbAKQKuoTuS8N4TQ'}
2) Using Bearer Token , data needs to be fetched. In Second step failing
jquery-dbg.js:10216 POST https://workspaces-ws-wllq8-app1.eu10.trial.applicationstudio.cloud.sap/document-information-extract... 503
controller
var url = "/document-information-extraction/v1/document/jobs";
var ajaxRequest = {};
ajaxRequest.url = url;
ajaxRequest.method = "POST";
ajaxRequest.headers = header;
ajaxRequest.data = data;
ajaxRequest.processData = false;
ajaxRequest.contentType = false;
ajaxRequest.mimeType = "multipart/form-data";
ajaxRequest.success = successcallback.bind(this);
ajaxRequest.error = failcallback.bind(this);
jQuery.ajax(ajaxRequest);
ui5.yaml
backend:
- path: /oauth
destination: DocExtract
- path: /document-information-extraction
destination: DocExtract_CLONING
xs-app.json
"routes": [
{
"source": "^/oauth/(.*)$",
"target": "/oauth/$1",
"destination": "DocExtract",
"authenticationType": "xsuaa",
"csrfProtection": false
},
{
"source": "^/document-information-extraction/(.*)$",
"target": "/document-information-extraction/$1",
"destination": "DocExtract_CLONING",
"authenticationType": "none",
"csrfProtection": false
},
I think you're using the destinations incorrectly here. Afaik it's not possible to communicate with the authentication.eu10.hana.ondemand.com endpoint via basic authentication.
And there's also no need to fetch OAuth tokens from the UI5 app as you can use the approuter for this. I recommend that you read my post Using the Destination service in SAP BTP, Cloud Foundry Environment. I hope this explains all the needed details for you use-case.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.