Skip to Content
0

Read IoT-MMS Tables - OData API

Feb 19 at 11:04 AM

61

avatar image

Hello,

I have the SCP IoT Service and I would like to get the data from Message Management Service Cockpit:

When you want to display the stored messages, you can access the OData API.

Service Root - https://iotmmsXXX.hana.ondemand.com/com.sap.iotservices.mms/v1/api/http/app.svc Metadata - https://iotmmsXXX.hana.ondemand.com/com.sap.iotservices.mms/v1/api/http/app.svc/$metadata

I would like to consume this service on a SAPUI5 app, using Eclipse, not Web Ide, so how can I do this? Without using destinations.

If i try like :

$.ajax({
	method: 'GET',
	url: url,
	dataType: 'json',
	cache : false,
	crossDomain : true,
	success: function(data, status) {
	    debugger;
	},
	beforeSend: function(xhr, settings) {
            xhr.setRequestHeader('Authorization','Bearer ' + token);
        } 
});

I get this error:

Failed to load https://iotmmsXXX.hanatrial.ondemand.com/com.sap.iotservices.mms/v1/api/http/app.svc/SYSTEM.T_IOT_91605E2D548E061B26BC?$format=json Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://XXXXXX:xxx' is therefore not allowed access. The response had HTTP status code 401.

If I'm using proxy from eclipe it works, but when I upload my app to our System, it give me again the same error.

Can anyone help me with this issue?

Thanks in advance

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Ivan Mirisola
Feb 19 at 12:54 PM
0

Hi Cristian,

That error message means you are trying to violate the SOP implemented on most modern browsers to avoid Cross Site Scripting.

All requests started from your UI5 application need to be routed thru the same domain. Thus, either you implement a proxy in Cloud Platform or use the destination features provided to you via cockpit. I'd recommend using the standard feature. However, if you chose a more complex way, check out this project on github.

Regards,
Ivan

Share
10 |10000 characters needed characters left characters exceeded