Skip to Content

SAP OCR Machine Language..?

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);
			},
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers