cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 1.30.8 OData Model - create function fail

Former Member
0 Kudos

I am hosting a UI5 application on HCP.

UI5 Version 1.30.8 has been recently released, and HCP automatically runs the latest version of UI5.

I have an OData model in my application, on which I performed a "create" (or HTTP POST) on version 1.28.9 successfully.

Since the UI5 upgrade this POST has stopped working.

I get the following error:

First the "refresh security token" request, which gets a 200 and the CSRF token, followed by the POST. Which isn't even attempted.

The Request:

In the error handler I got this text: "The following problem occurred: Failed to execute 'send' on 'XMLHttpRequest".

Any ideas why this is happening?

My code is here:


var mODataModel = new sap.ui.model.odata.ODataModel("/ticketupdater");

  mODataModel.setDefaultBindingMode(sap.ui.model.BindingMode.TwoWay);

  oComponent.setModel(mODataModel, "ticket");

  mODataModel.refreshSecurityToken();

  mODataModel.create("/SEOD_TicketUpdater_BORootCollection",

  oUpdate Obj, //JSON object for creation

  {

  async : false,

  success : function(oData){

     //handle success (code removed)

  }, error : function(err){

       //handle error (code removed)

  }

  }

  );

When I do this POST in a rest client or from an older version UI5 application, the request works perfectly. So it is an issue with doing the POST from this version of UI5, I believe. I cannot see any difference in the OData model control in the SAPUI5 sdk though, for create...

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I've had a thought: perhaps the issue isn't with 1.30, but with a change on HCP: I am running the application on HCP (which points to version 1.30) and it doesn't work, but when I run it locally it does. However it USED to work on HCP...

Former Member
0 Kudos

Tested this theory by downloading 1.30 and running locally... and it works!

So the issue must be on HCP..

Maybe something on my destination, which my neo-app.json is pointing to...

Former Member
0 Kudos

I was missing HTTPS in my destination, and instead pointing to HTTP.

Fixing this resolved the issue, no code change required

thank you

Answers (3)

Answers (3)

Former Member
0 Kudos

I don't think you'd need to manually refresh the security token using refreshSecurityToken() ! The oData model create would take care of that. Try without using refreshSecurityToken().

Former Member
0 Kudos

Thanks, I'll try this.

But the reason for refreshing the token was that between the creation of my OData model, and the first POST there could be a large time-lapse, and I was experiencing expired token issues in version 1.28.

But I will try this and get back to you, thanks for the suggestion.

Former Member
0 Kudos

Unfortunately this did not resolve my issue

There is no attempt to POST to the OData service still: the "send" fails, the request never leaves the OData model from what I can tell..

I get the message: "The following problem occurred: Failed to execute 'send' on 'XMLHttpRequest': Failed to load"

former_member182372
Active Contributor
0 Kudos

try to call like this

refreshSecurityToken($.noop, $.noop, false)

Former Member
0 Kudos

I will try this. But to be clear, the refresh security token works perfectly, and returns a good CSRF token.

But I will test this (I may not understand the reasoning )

former_member182372
Active Contributor
0 Kudos

by default it is async and when you call create, token might not be back yet

Former Member
0 Kudos

Thanks, good though

Sadly this didn't work. Same response

former_member182372
Active Contributor
0 Kudos

try to run in debug mode (cntrl+alt+shift+p, check Use Debug Sources (reload)) so it prints lines from not minified version

Former Member
0 Kudos

Like this?

and this?

former_member182372
Active Contributor
0 Kudos

yes, thats good, post also the one from datajs please

former_member182372
Active Contributor
0 Kudos

anything in console? stack trace? where exactl that exception happens

Former Member
0 Kudos

This is the stack trace.

In the console:

(sorry for not including these in the first post)

Thank you!

former_member182372
Active Contributor
0 Kudos

expend the second error too

Former Member
0 Kudos
Former Member
0 Kudos

RESOLVED: the issue was my destination in HCP was set up as http, not https! So the GET's were working, but the POST was failing. Still unsure why the error text wasn't more informative