Cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve Data from mobile application

Experimenter
Experimenter

Hello everybody,

 

We are creating a mobile application that needs to get data from Mindsphere. We have developed a MindSphere app with some REST API's that return some time series from the database. It actually works when we access the endpoint from any browser like Chrome, but when I try to access the same endpoint from my mobile application (developed in Ionic, if it helps), I get a CORS error:

 

Invalid CORS request

 

Access to XMLHttpRequest at 'https://*********.eu1.mindsphere.io/gettoken.php' from origin 'http://localhost' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I've search a lot but I didn't find anything useful. and many discussions are old, or the links are broken, that is why I'm opening a new discussion.

 

Is there any way to access the data from MindSphere from a mobile Application using REST API's?? 

 

Thanks for the help,

Carlos Roig

1 REPLY 1
Highlighted

Re: Retrieve Data from mobile application

Siemens Creator Siemens Creator
Siemens Creator

Error can be resolved by adding A-C-A-O header in MindApp API response. 

 

Sample code snippet:-

HttpHeaders headers = new HttpHeaders();
headers.add("Access-Control-Allow-Origin", "*");

return new ResponseEntity<>(<responseBody>,headers,HttpStatus.OK);

 

Since accessing MindApp API from postman without interceptor being tried and getting same CORS error.

Enabling interceptor resolves this error from postman.