2020 Jan 17 11:12 AM
Hi,
I am developing a nodejs application, which fetches data from an on-premise OData service and returns it back as a response. This is my node js application's code.
server.js
var http = require('http');
var express = require('express')
var request= require('request')
const bodyParser = require('body-parser')
const turl = require('turl')
var app = express()
const port =process.env.PORT ||3000
app.use(bodyParser.json())
app.use(express.static(__dirname));
var url ='http://10.124.2.117:8000/sap/opu/odata/sap/ZGW_EMPLOYEE_INFO_SRV/EmployeeHeaderSet';
app.get('/',async(req,res)=>{
var headers={
'Content-Type':'application/json',
'Accept':'application/json',
'Authorization':'Basic YmFkaHKzaGE6YWlodGhhPXI=',
"x-csrf-token" : "Fetch"};
var options={
method:'GET',
url: url,
headers:headers
};
request(options,function(error, response, body){
if(!error && response.statusCode ==200){
var resultData = JSON.parse(body);//Process the dataandreturn the response
}
else{
console.log("Error happened");
}
});
});
app.listen(port,()=>{
console.log('Server is running on port '+port)})
<br>
<br>
manifest.yaml
---
applications:-name: myapp
random-route: true
path: myapp
memory:128M
health-check-type:none
services:- myuaa
xs-app.json
{"xsappname" : "myapp","tenant-mode" : "dedicated"}
When I run this application on the local system it is returning the response as expected, but when I deploy this node js application to the Cloudfoundry Environment, it is showing "Error happened".
Is there any other way to consume the data ?
What is the problem with my code?
Thanks in advance
Note: I am using TM System
2020 Jan 17 3:04 PM
As the system you are trying to call is not available in public, the request fails of course when it is executed in the CF environment.
You have to use the Connectivity service to access your on-premise system via SAP Cloud Connector. For details please check the online documentation: Consuming the Connectivity Service
Hi,
I am developing a nodejs application, which fetches data from an on-premise OData service and returns it back as a response. This is my node js application's code.
server.js
var http = require('http');
var express = require('express')
var request= require('request')
const bodyParser = require('body-parser')
const turl = require('turl')
var app = express()
const port =process.env.PORT ||3000
app.use(bodyParser.json())
app.use(express.static(__dirname));
var url ='http://10.124.2.117:8000/sap/opu/odata/sap/ZGW_EMPLOYEE_INFO_SRV/EmployeeHeaderSet';
app.get('/',async(req,res)=>{
var headers={
'Content-Type':'application/json',
'Accept':'application/json',
'Authorization':'Basic YmFkaHKzaGE6YWlodGhhPXI=',
"x-csrf-token" : "Fetch"};
var options={
method:'GET',
url: url,
headers:headers
};
request(options,function(error, response, body){
if(!error && response.statusCode ==200){
var resultData = JSON.parse(body);//Process the dataandreturn the response
}
else{
console.log("Error happened");
}
});
});
app.listen(port,()=>{
console.log('Server is running on port '+port)})
<br>
<br>
manifest.yaml
---
applications:-name: myapp
random-route: true
path: myapp
memory:128M
health-check-type:none
services:- myuaa
xs-app.json
{"xsappname" : "myapp","tenant-mode" : "dedicated"}
When I run this application on the local system it is returning the response as expected, but when I deploy this node js application to the Cloudfoundry Environment, it is showing "Error happened".
Is there any other way to consume the data ?
What is the problem with my code?
Thanks in advance
Note: I am using TM System
2020 Jan 17 3:04 PM
As the system you are trying to call is not available in public, the request fails of course when it is executed in the CF environment.
You have to use the Connectivity service to access your on-premise system via SAP Cloud Connector. For details please check the online documentation: Consuming the Connectivity Service
2020 Jan 21 6:30 AM
2020 Jan 21 6:33 AM
Just a simple search here in the community brings up a lot of results. For instance https://blogs.sap.com/2017/07/09/how-to-use-the-sap-cloud-platform-connectivity-and-the-cloud-connec...
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |