Skip to Content
May 07, 2019 at 04:30 PM

Cloud foundry sapui5 app: ajax post request 403 forbidden

1761 Views Last edit May 08, 2019 at 12:06 PM 2 rev

Hi Community,

I'm trying around in cf trial and wanted to do a post request with ajax to my node-js backend with express. But unfortunately I get an 403 forbidden error. All GET requests (with this.getView().getModel("...").loadData("/layoutapi/objectgroups");) instead work fine.

So what is best practice for doing a post request and where could I have missed something?

Please let me also know, if there is someone who can do ajax post requests as in my case without errors.

Best regards!

onSavePressed: function () {
     var url = "/eventapi/object";
		type: "POST",
		url: url,
		data: oEventModel.getData(),
		dataType: "json",
		contentType: "application/json",
		success: function (result) {
		error: function (e) {

This is my approuter:

	"welcomeFile": "/cfElbTrigger/index.html",
	"authenticationMethod": "route",
	"logout": {
		"logoutEndpoint": "/do/logout"
	"routes": [{
		"source": "^/cfElbTrigger/(.*)$",
		"target": "$1",
		"localDir": "webapp"
	}, {
		"source": "^/eventapi/([a-z]+)",
		"target": "eventapi/$1",
                "authenticationType": "xsuaa",
		"destination": "backend_api"

And this is in app.js to authenticate tenants:

var xsenv = require('@sap/xsenv');
var JWTStrategy = require('@sap/xssec').JWTStrategy;
var passport = require('passport');

var services = xsenv.getServices({ uaa: { tag: "xsuaa" }});
passport.use(new JWTStrategy(services.uaa));
oApp.use(passport.authenticate('JWT', {
	session: false