文档信息提取-SAPUI5 Ajax POST调用

2020-08-14 10:33发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)我正在尝试将pdf发布到 doc...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


我正在尝试将pdf发布到" document-information-extraction/v1/document/jobs"中以进行处理并提取文本。 邮寄电话就是这样-

var data1 = new FormData();

this.onuploadFile是pdf文件。

data1.append(" file",this.onuploadFile," mypdf"); data1.append(" options"," {\" extraction \":{\" headerFields \":[\" documentNumber \",\" taxId \",\" taxName \",\" purchaseOrderNumber \",\" shippingAmount \",\" netAmount \",\" senderAddress \",\" senderName \",\" grossAmount \",\" currencyCode \",\" receiverContact \",\" documentDate \",\" taxAmount \ ",\" taxRate \",\" receiverName \",\" receiverAddress \"],\" lineItemFields \":[\" description \",\" netAmount \",\" quantity \",\" unitPrice \ ",\" materialNumber \"]},\" clientId \":\" c_00 \",\" documentType \":\" invoice \",\" enrichment \":{\" sender \":{\" top \":5,\" type \":\" businessEntity \",\" subtype \":\"供应商\"},\"员工\":{\" type \":\"员工\"} }}");

var settings = {" url":"/img/DIC_trial_API/document/jobs"," method":" POST"," timeout":0," headers":{" Authorization":" Bearer" + bearerToken}, " processData":false," mimeType":" multipart/form-data"," contentType":false," data":data1};

$。ajax(settings).done(function(response){console.log(response);});

响应为" 400错误",消息为" {"错误":{"代码":" 4","消息":"未提供所需的表单数据。","详细信息":[{ 代码":" 0","消息":"选项"}]}}"。

如果formdata或post调用方法有任何问题,谁能帮忙?

7条回答
SC_Yao
2020-08-14 11:15

克里斯托夫·嗨,

我在某处读到,如果我们将内容类型设置为未定义,它将根据发送的数据来选择类型。 因此,代码现在看起来像这样-

 jQuery.sap.domById(fileuploader.getId()+" -fu")。setAttribute(" type"," file");  data1.append(" file",jQuery.sap.domById(fileuploader.getId()+" -fu")。files [0]);
 var blob = new Blob([JSON.stringify(options)],{type:'application/json'});
 data1.append(" options",blob);
 jQuery.ajax({url:"/img/DIC_trial_API/document/jobs,data:data1," headers":{" Content-Type":undefined," Authorization":" Bearer" + bearerToken},缓存:false,processData:  false,方法:" POST",
 成功:功能(数据){
 console.log(data);  },
 错误:function(err){console.log(err);  }});
 

然后,将内容类型设置为" application/x-www-form-urlencoded; charset = UTF-8",并且表单数据看起来为空- ty-formdata.jpg

并且,当从swagger UI测试API时,formdata看起来像-

一周热门 更多>