Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SAP OCR Machine Language..?

former_member187227
Participant
0 Kudos

Hi Experts,

I am trying the OCR concept in sapui5, but getting 400 error while post the .pdf  or .jpg file. kindly suggest some idea also i have shared my code below.
getOCR: function(oEvent) {
				var sHeaders = {
					"content-type": "multipart/form-data",
					"Accept": "application/json",
					"APIKey": "pAW3FFdekU24Ao2m7VCzhXARr3JPzboN"
				};
				var url  = "https://sandbox.api.sap.com/ml/ocr/ocr";
				var data = new FormData();
	                       // this is file object
				data.append('file', this.getView().byId("fileUploader").getFocusDomRef().files[0]);
				data.append('lang', "en");
				data.append('output_type', 'txt');
				this.webRequest(url,data,sHeaders,this.onOCRDetectedSuccess.bind(this),this.onOCRDetectedFailed);




			},
			onOCRDetectedSuccess: function(data) {
				console.log(data);
			},
			onOCRDetectedFailed: function(data) {
				console.log(data);
			
			},
			webRequest:function(url,data,header,successcallback,failcallback){
				var ajaxRequest = {};
				console.log(url)
				ajaxRequest.url = url;
				ajaxRequest.method = "POST";
				ajaxRequest.headers = header;
				ajaxRequest.data = data;
				ajaxRequest.processData = false;
				ajaxRequest.contentType = false;
				ajaxRequest.cache = false;
				ajaxRequest.success  = successcallback.bind(this);
				ajaxRequest.error = failcallback.bind(this);
				jQuery.ajax(ajaxRequest);
			},
0 REPLIES 0