首页 > 解决方案 > WSO2 EI-如何在 WSO2 中通过 URL(发布)附加和接收“表单数据”(附件)?

问题描述

我的 WSO2 代码应该通过 PostMan 请求接收文件附件。然后我必须形成一个 HTTP 请求以连接到 Zoho Portal,在其中我必须将文件附件作为表单数据类型作为 Post 方法发送。

作为附件发送的文件将被发送到Zoho 任务创建端点,以便使用 Document 创建任务。

注意:当我尝试通过调用Zoho Task APi直接使用邮递员发送附件时,它成功地创建了一个带有附件的任务,但无法使用 WSO2 代码执行相同的操作。

我的 WSO2 代码:

<resource methods="POST" uri-template="/createTask?PortalId={portalid}&amp;ProjectId={projectid}">
    <inSequence>
        <log level="custom">
            <property name="Welcome Logger" value="=== Task Creation API Started ==="/>
            <property expression="get-property('uri.var.portalid')" name="uri.var.portalId"/>
            <property expression="get-property('uri.var.projectid')" name="uri.var.ProjectId"/>
        </log>
        <property description="Configuration" expression="get-property('ZohoApp-Config')" name="ZohoAppConfig" scope="axis2" type="OM"/>
        <property expression="get-property('registry','gov:/ZohoConfig/ZohoAppConfigFile.txt')" name="accessToken" scope="default" type="STRING"/>
        <property description="RefreshToken" expression="$axis2:ZohoAppConfig//*[local-name()='refreshToken']/text()" name="refreshToken" scope="default" type="STRING"/>
        <property description="BaseUri" expression="$axis2:ZohoAppConfig//*[local-name()='PortalDetails']/text()" name="uri.var.BaseURI" scope="default" type="STRING"/>
        <property expression="json-eval($.task_name)" name="uri.var.task_name" scope="default" type="STRING"/>
        <property description="URI1" name="uri.var.Projects" scope="default" type="STRING" value="projects"/>
        <property description="URI2" name="uri.var.Tasks" scope="default" type="STRING" value="tasks"/>
        
        <filter regex="false" source="get-property('uri.var.task_name')=''">
            <then>
                <property expression="fn:concat('name=',get-property('uri.var.task_name'),'&amp;person_responsible=',get-property('uri.var.owner_id'),'&amp;description=',get-property('uri.var.description'),'&amp;priority=',get-property('uri.var.priority'))" name="uri.var.taskdetails" scope="default" type="STRING"/>
                <log level="custom">
                    <property expression="fn:concat('name=',get-property('uri.var.task_name'),'&amp;person_responsible=',get-property('uri.var.owner_id'),'&amp;description=',get-property('uri.var.description'),'&amp;priority=',get-property('uri.var.priority'))" name="uri.var.taskdetails"/>
                </log>
                <header expression="fn:concat('Bearer ', get-property('accessToken'))" name="Authorization" scope="transport"/>
                <call>
                    <endpoint>
                        <http method="post" uri-template="{uri.var.BaseURI}/{uri.var.portalid}/{uri.var.Projects}/{uri.var.projectid}/{uri.var.Tasks}/?name={uri.var.task_name}&amp;person_responsible={uri.var.owner_id}&amp;description={uri.var.description}&amp;priority={uri.var.priority}&amp;">
                            <suspendOnFailure>
                                <initialDuration>-1</initialDuration>
                                <progressionFactor>1</progressionFactor>
                            </suspendOnFailure>
                            <markForSuspension>
                                <retriesBeforeSuspension>0</retriesBeforeSuspension>
                            </markForSuspension>
                        </http>
                    </endpoint>
                </call>
                <property description="ResponseMessage" expression="json-eval($.error.message)" name="ResponseMessage" scope="default" type="STRING"/>
                <log level="custom">
                    <property expression="json-eval($)" name="==== Task Creation Response ===="/>
                    <property expression="get-property('axis2','HTTP_SC')" name="==== HTTP Status Code ===="/>
                </log>
                
                <log>
                    <property name="Process Status" value="=== Completed ==="/>
                </log>
                <respond/>
            </then>
            <else>
                <log>
                    <property name="Response" value="=== Task Name Missing ==="/>
                </log>
                <respond/>
            </else>
        </filter>
        <respond/>
    </inSequence>
    <outSequence/>
    <faultSequence/>
</resource>

谁能告诉我如何在 WSO2 EI 6.1.1 的 API 中实现这一点

标签: wso2multipartform-datawso2esbwso2eizoho

解决方案


推荐阅读