cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Machine learning image classifier service in sapui5 app not working

e_giunta
Participant
0 Kudos

Hello, I've followed some tutorials to use ml imageclassifier service with sapui5 application developed with web ide. I try to use service directly on SAP API Business Hub (https://api.sap.com/shell/discover/contentpackage/SAPLeonardoMLFunctionalServices/api/image_classifi...) and everything it's ok, then I get the API Key and use it in code, but no one application is working. I use the following tutorials (link below) and I get this errors:


- https://blogs.sap.com/2018/01/19/consume-machine-learning-api-in-sapui5/

ERROR (console): Failed to load resource: the server responded with a status of 400 (Bad Request) extended_runnable_file.html:1 Failed to load https://sandbox.api.sap.com/ml/imageclassifier/inference_sync: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://webidetesting9605175-s00xxxxxxx3trial.dispatcher.hanatrial.ondemand.com' is therefore not allowed access. The response had HTTP status code 400. Main.controller.js?eval:58 library.css Failed to load resource: the server responded with a status of 404 (Not Found)

--------------------------------------------------------------------------------------------------------------------
- https://www.sap.com/developer/tutorials/ml-fs-sapui5-img-classification.html

ERROR (dialog): Error 400 : This service requires at least 1 file. Please put your file(s) into the `files` field of the POST request

ERROR (console): Failed to load resource: the server responded with a status of 400 (Bad Request) - Failed to load resource: the server responded with a status of 404 (Not Found)

--------------------------------------------------------------------------------------------------------------------

- https://blogs.sap.com/2017/08/11/sap-leonardo-machine-learning-api-with-a-ui5-application/

ERROR (console): Failed to load resource: the server responded with a status of 404 (Not Found) extended_runnable_file.html?hc_orionpath=%2Fs00xxxxxxx3trial%24s00xxxxxxx3-OrionContent%2FProductClassificationML∨igional-url=index.html&sap-ui-appCacheBuster=..%2F&sap-ui-xx-componentPreload=off:1 Failed to load https://sandbox.api.sap.com/ml/imgclassifier/inference_sync: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://webidetesting9605175-s00xxxxxxx3trial.dispatcher.hanatrial.ondemand.com' is therefore not allowed access. The response had HTTP status code 404.


Any suggestion?

Accepted Solutions (0)

Answers (1)

Answers (1)

abdel_dadouche
Active Contributor
0 Kudos

Hi e.giunta

I'm surprised you are getting these errors with https://www.sap.com/developer/tutorials/ml-fs-sapui5-img-classification.html.

Can you open the browser developer tools (press F12), and inspect the request headers, and may be share it?

The FileUploader usually take care of all the plumbing when you need it. Unless you are using the Ajax or XHR mode provided in the tutorial?

Regards