用例:
Note:当我通过调用Zoho任务创建API直接尝试与邮递员打交道时,它用文档创建任务。
有谁能让我知道如何在WSO2 EI 6.1.1的API中实现这一点?
邮差:

当我将日志level=“完全”放入api中时,就会出现在日志下面。

当我通过在线工具对其进行解码时,base64解码的内容如下所示。

API代码:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/uploadAttachment" name="AtatchmentAPI" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST">
<inSequence>
<property name="messageType" scope="axis2" type="STRING" value="multipart/form-data"/>
<!-- <log level="full"/> -->
<log level="custom">
<property name="========UploadAttachment" value=" API Called=========="/>
<property name="========AttachmentName===" expression="get-property('transport', 'filename')"/>
</log>
<property expression="get-property('registry','gov:/ZohoConfig/ZohoAppConfigFile.txt')" name="accessToken" scope="default" type="STRING"/>
<!-- <log level="full"/> -->
<payloadFactory media-type="xml">
<format>
<ns:binary xmlns:ns="http://ws.apache.org/commons/ns/payload">$1</ns:binary>
</format>
<args>
<arg evaluator="xml" expression="//*[local-name()='binary']/text()"/>
</args>
</payloadFactory>
<script language="js">
<![CDATA[
var binaryNode =
mc.getEnvelope().getBody().getFirstElement().getFirstOMChild();
binaryNode.setBinary(true);
]]>
</script>
<property name="attachment_base64" expression="$body"/>
<log level="custom">
<property name="====attachment_base64====" expression="$body"></property>
</log>
<payloadFactory description="Form Response Payload" media-type="json">
<format>{"uploaddoc":$1}</format>
<args>
<arg evaluator="xml" expression="$ctx:attachment_base64"/>
</args>
</payloadFactory>
<log level="custom">
<property name="====uploaddoc_Payload====" expression="$body"></property>
</log>
<!-- <log level="full"/> -->
<property name="transport.vfs.ReplyFileName" value="ZohoTestFile.txt" scope="transport"/>
<property name="transport.vfs.Streaming" value="true" scope="transport"/>
<property name="ClientApiNonBlocking" action="remove" scope="axis2"/>
<property name="messageType" scope="axis2" value="application/binary"/>
<property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
<header expression="fn:concat('Bearer ', '1000.CCCCCCCCCC.XXXXXXXXXXXXXXXXXX')" name="Authorization" scope="transport"/>
<call>
<endpoint>
<address uri="https://projectsapi.zoho.com/restapi/portal/36249112/projects/685798000000976352/tasks/685798000011774999/attachments/"/>
</endpoint>
</call>
<log>
<property expression="json-eval($.)" name="==API Response======"/>
</log>
<!-- <payloadFactory description="Form Response Payload" media-type="json">
<format>{"recipients":"Regularrrrrrrrrrrrr"}</format>
<args/>
</payloadFactory>
<log>
<property expression="json-eval($.)" name="==Final- CampaignBuilder_JsonRequest_ForCreation======"/>
</log> -->
<respond/>
<!-- <property expression="String(//mediate/file/@filename)" name="filename" scope="default" type="STRING"/> -->
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>API响应:
{
"error": {
"code": 6831,
"message": "Input Parameter Missing"
}
}原因:在调用Zoho时,需要将附件传递给称为"uploaddoc“的参数。在这里,我不知道如何设置该字段的附件
导线日志:
3:04:42,565] [] INFO - APIDeployer API named 'AtatchmentAPI' has been deployed from file : D:\ServerSetup 6.1.1\wso2ei-6.1.1\wso2\tmp\carbonapps\-1234\1602833682469Att
-CAR_1.0.0.car\AtatchmentAPI_1.0.0\AtatchmentAPI-1.0.0.xml
3:04:42,565] [] INFO - ApplicationManager Successfully Deployed Carbon Application : AttachmentUpload-CAR_1.0.0 {super-tenant}
3:05:04,362] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "POST /uploadAttachment HTTP/1.1[\r][\n]"
3:05:04,363] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "User-Agent: PostmanRuntime/7.26.5[\r][\n]"
3:05:04,363] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Accept: */*[\r][\n]"
3:05:04,363] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Postman-Token: 21c46ad2-19fc-46a6-aea8-8113ac70817e[\r][\n]"
3:05:04,363] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Host: localhost:8280[\r][\n]"
3:05:04,363] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Accept-Encoding: gzip, deflate, br[\r][\n]"
3:05:04,364] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Connection: keep-alive[\r][\n]"
3:05:04,364] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Content-Type: multipart/form-data; boundary=--------------------------623932778277436708655778[\r][\n]"
3:05:04,364] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Cookie: bf42f62d55=64dc75f94d2bd72d94493d263847c08c[\r][\n]"
3:05:04,364] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Content-Length: 376[\r][\n]"
3:05:04,365] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "[\r][\n]"
3:05:04,365] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "----------------------------623932778277436708655778[\r][\n]"
3:05:04,365] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Content-Disposition: form-data; name="uploaddoc"; filename="ZohoAttachment.txt"[\r][\n]"
3:05:04,365] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Content-Type: text/plain[\r][\n]"
3:05:04,366] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "[\r][\n]"
3:05:04,370] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Hi,[\r][\n]"
3:05:04,371] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "This is zoho Attachment task[\r][\n]"
3:05:04,371] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "----------------------------623932778277436708655778[\r][\n]"
3:05:04,371] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "Content-Disposition: form-data; name="name"[\r][\n]"
3:05:04,373] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "[\r][\n]"
3:05:04,373] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "TaskAttachment Demo[\r][\n]"
3:05:04,373] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 >> "----------------------------623932778277436708655778--[\r][\n]"
3:05:04,373] [] INFO - LogMediator ========UploadAttachment = API Called==========, ========AttachmentName=== = null
3:05:04,398] [] INFO - LogMediator ====attachment_base64==== = <soapenv:Body xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><ns:binary xmlns:ns="http://ws.apa
ns/ns/payload">LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTYyMzkzMjc3ODI3NzQzNjcwODY1NTc3OA0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJ1cGxvYWRkb2MiOyBmaWxlbmFtZT0iW
1lbnQudHh0Ig0KQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluDQoNCkhpLA0KVGhpcyBpcyB6b2hvIEF0dGFjaG1lbnQgdGFzaw0KLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTYyMzkzMjc3ODI3NzQzNjcwODY1NTc3OA
EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJuYW1lIg0KDQpUYXNrQXR0YWNobWVudCBEZW1vDQotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tNjIzOTMyNzc4Mjc3NDM2NzA4NjU1Nzc4LS0NCg==</ns:binary
dy>
3:05:04,402] [] INFO - LogMediator ====uploaddoc_Payload==== = <soapenv:Body xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><uploaddoc xmlns="http://ws.apache
se">LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTYyMzkzMjc3ODI3NzQzNjcwODY1NTc3OA0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJ1cGxvYWRkb2MiOyBmaWxlbmFtZT0iWm9ob0F0dGFj
g0KQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluDQoNCkhpLA0KVGhpcyBpcyB6b2hvIEF0dGFjaG1lbnQgdGFzaw0KLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTYyMzkzMjc3ODI3NzQzNjcwODY1NTc3OA0KQ29udGVud
lvbjogZm9ybS1kYXRhOyBuYW1lPSJuYW1lIg0KDQpUYXNrQXR0YWNobWVudCBEZW1vDQotLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tNjIzOTMyNzc4Mjc3NDM2NzA4NjU1Nzc4LS0NCg==</uploaddoc></soapenv:
3:05:05,124] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "POST /restapi/portal/36249008/projects/685798000009576352/tasks/685798000011774013/attachments/ HTTP/1.1[
3:05:05,126] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Authorization: Bearer 1000.9df1f22e7d16ba95f0553af9855d40b5.f81f2af95682c8b398d0bb4939190d10[\r][\n]"
3:05:05,127] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Cookie: bf42f62d55=64dc75f94d2bd72d94493d263847c08c[\r][\n]"
3:05:05,127] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "transport.vfs.Streaming: true[\r][\n]"
3:05:05,127] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Accept: */*[\r][\n]"
3:05:05,128] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Postman-Token: 21c46ad2-19fc-46a6-aea8-8113ac70817e[\r][\n]"
3:05:05,128] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Accept-Encoding: gzip, deflate, br[\r][\n]"
3:05:05,128] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "transport.vfs.ReplyFileName: ZohoTestFile.txt[\r][\n]"
3:05:05,129] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Content-Type: application/binary[\r][\n]"
3:05:05,129] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Transfer-Encoding: chunked[\r][\n]"
3:05:05,129] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Host: projectsapi.zoho.com[\r][\n]"
3:05:05,130] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "Connection: Keep-Alive[\r][\n]"
3:05:05,130] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
3:05:05,130] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "[\r][\n]"
3:05:05,131] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "237[\r][\n]"
3:05:05,131] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "<uploaddoc xmlns="http://ws.apache.org/ns/synapse">LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTYyMzkzMjc3ODI3Nz
3OA0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJ1cGxvYWRkb2MiOyBmaWxlbmFtZT0iWm9ob0F0dGFjaG1lbnQudHh0Ig0KQ29udGVudC1UeXBlOiB0ZXh0L3BsYWluDQoNCkhpLA0KVGhpcyBpcyB
aG1lbnQgdGFzaw0KLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLTYyMzkzMjc3ODI3NzQzNjcwODY1NTc3OA0KQ29udGVudC1EaXNwb3NpdGlvbjogZm9ybS1kYXRhOyBuYW1lPSJuYW1lIg0KDQpUYXNrQXR0YWNobWVu
S0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tNjIzOTMyNzc4Mjc3NDM2NzA4NjU1Nzc4LS0NCg==</uploaddoc>[\r][\n]"
3:05:05,134] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "0[\r][\n]"
3:05:05,135] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 << "[\r][\n]"
3:05:05,905] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "HTTP/1.1 400 [\r][\n]"
3:05:05,906] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Server: ZGS[\r][\n]"
3:05:05,906] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Date: Fri, 16 Oct 2020 07:35:06 GMT[\r][\n]"
3:05:05,906] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Content-Type: application/json;charset=utf-8[\r][\n]"
3:05:05,906] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Content-Length: 60[\r][\n]"
3:05:05,907] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Connection: keep-alive[\r][\n]"
3:05:05,907] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "X-Content-Type-Options: nosniff[\r][\n]"
3:05:05,907] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "X-XSS-Protection: 1[\r][\n]"
3:05:05,908] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Set-Cookie: zpct=24a027ad-3cd2-4edf-b641-b792d3ffede8;path=/;SameSite=None;Secure;priority=high[\r][\n]"
3:05:05,908] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Set-Cookie: _zcsr_tmp=24a027ad-3cd2-4edf-b641-b792d3ffede8;path=/;SameSite=Strict;Secure;priority=high[\r
3:05:05,908] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Pragma: no-cache[\r][\n]"
3:05:05,909] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Cache-Control: no-cache[\r][\n]"
3:05:05,909] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Expires: Thu, 01 Jan 1970 00:00:00 GMT[\r][\n]"
3:05:05,909] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Set-Cookie: JSESSIONID=9FD064E43DACD49060E958A34C2E0325; Path=/; Secure[\r][\n]"
3:05:05,909] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "X-Frame-Options: SAMEORIGIN[\r][\n]"
3:05:05,910] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "X-UA-Compatible: IE=9, IE=10[\r][\n]"
3:05:05,910] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "Content-Disposition: attachment; filename=response.txt;[\r][\n]"
3:05:05,910] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "X-Download-Options: noopen[\r][\n]"
3:05:05,910] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "[\r][\n]"
3:05:05,910] [] DEBUG - wire HTTPS-Sender I/O dispatcher-4 >> "{"error":{"code":6831,"message":"Input Parameter Missing"}}[\n]"
3:05:05,921] [] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:49cdf6b1-0ac6-4728-bc92-f8658b4a88
: request, ==API Response====== = {"error":{"code":6831,"message":"Input Parameter Missing"}}
3:05:05,925] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "HTTP/1.1 400 [\r][\n]"
3:05:05,925] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "X-Frame-Options: SAMEORIGIN[\r][\n]"
3:05:05,925] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "X-UA-Compatible: IE=9, IE=10[\r][\n]"
3:05:05,926] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Cache-Control: no-cache[\r][\n]"
3:05:05,927] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "X-Content-Type-Options: nosniff[\r][\n]"
3:05:05,927] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Content-Disposition: attachment; filename=response.txt;[\r][\n]"
3:05:05,927] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "X-Download-Options: noopen[\r][\n]"
3:05:05,927] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Set-Cookie: JSESSIONID=9FD064E43DACD49060E958A34C2E0325; Path=/; Secure[\r][\n]"
3:05:05,927] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Set-Cookie: _zcsr_tmp=24a027ad-3cd2-4edf-b641-b792d3ffede8;path=/;SameSite=Strict;Secure;priority=high[\
3:05:05,928] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Set-Cookie: zpct=24a027ad-3cd2-4edf-b641-b792d3ffede8;path=/;SameSite=None;Secure;priority=high[\r][\n]"
3:05:05,928] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Expires: Thu, 01 Jan 1970 00:00:00 GMT[\r][\n]"
3:05:05,929] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Pragma: no-cache[\r][\n]"
3:05:05,929] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "X-XSS-Protection: 1[\r][\n]"
3:05:05,929] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Content-Type: application/json;charset=utf-8[\r][\n]"
3:05:05,930] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Date: Fri, 16 Oct 2020 07:35:05 GMT[\r][\n]"
3:05:05,930] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Transfer-Encoding: chunked[\r][\n]"
3:05:05,930] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "Connection: Close[\r][\n]"
3:05:05,930] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "[\r][\n]"
3:05:05,931] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "3c[\r][\n]"
3:05:05,931] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "{"error":{"code":6831,"message":"Input Parameter Missing"}}[\n]"
3:05:05,931] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "[\r][\n]"
3:05:05,931] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "0[\r][\n]"
3:05:05,932] [] DEBUG - wire HTTP-Listener I/O dispatcher-2 << "[\r][\n]"有人能给我一个解决办法吗?
发布于 2020-10-19 14:29:20
查看您的代码,您将不会对传入的有效负载做任何事情。那你为什么要调解有效载荷?穿过它就行了。
发布于 2020-10-19 14:50:04
模拟zoho (使用任何简单的python、pip安装web服务器)和转储请求来自ESB,并查看请求中缺少什么。一些标题很可能丢失,内容处理内容-类型
API声明"name“参数是强制性的。
https://stackoverflow.com/questions/64347153
复制相似问题