如何使用loadrunner中的rest api调用上传文件?

时间:2019-07-05 07:53:06

标签: rest file-upload loadrunner vugen

我正在尝试通过rest-runner使用rest API将文件与XML主体一起上传。

请注意:我已经在脚本中添加了“ NFT_DMS.doc”文件,因此我没有提供任何文件路径。

我尝试了以下请求以及收到的错误消息。

尝试1


    web_submit_data("FileUpload",
        "Action={p_URL}OIM/rest/file/upload?metadata=<DMSDocRequest><referenceID><id><type>sdsID</type><value>40359072</value></id><id><type>clmID</type><value>2606</value></id></referenceID><fileName>NFT_DMS.doc</fileName><docTypes><docTypeID>488</docTypeID></docTypes><fileType>doc</fileType><uploadBy>CLIENT\\G01156119</uploadBy><docDate>{p_DocDate}</docDate><docName>NFT_{p_DocName}</docName><uploadDate>{p_DocDate}</uploadDate><docVer>1</docVer><docSource>CLM</docSource><expDateTime>{p_ExpiryDate}</expDateTime><action>upload</action><docCategory><value>Others</value></docCategory></DMSDocRequest>",
        "Method=POST",
        "TargetFrame=",
        "EncType=multipart/form-data",
        "RecContentType=text/plain",
        "Mode=HTML",
     ITEMDATA,
        "Name=file", "Value=NFT_DMS.doc", "File=Yes", ENDITEM,
        LAST);


尝试2


    web_custom_request("Document1",
            "URL={p_URL}OIM/rest/file/upload?metadata=<DMSDocRequest><referenceID><id><type>sdsID</type><value>40359072</value></id><id><type>clmID</type><value>2606</value></id></referenceID><fileName>NFT_DMS.doc</fileName><docTypes><docTypeID>488</docTypeID></docTypes><fileType>doc</fileType><uploadBy>CLIENT\\G01156119</uploadBy><docDate>{p_DocDate}</docDate><docName>NFT_{p_DocName}</docName><uploadDate>{p_DocDate}</uploadDate><docVer>1</docVer><docSource>CLM</docSource><expDateTime>{p_ExpiryDate}</expDateTime><action>upload</action><docCategory><value>Others</value></docCategory></DMSDocRequest>",
            "Method=POST",
            "Resource=1",
            "RecContentType=text/plain",
            "Referer=",
            "Body=",
            "BodyFilePath=NFT_DMS.doc",
            LAST);

尝试3


    web_custom_request("Document1",
            "URL={p_URL}OIM/rest/file/upload?metadata=<DMSDocRequest><referenceID><id><type>sdsID</type><value>40359072</value></id><id><type>clmID</type><value>2606</value></id><id><type>sdsID</type><value>41821314</value></id><id><type>clmID</type><value>2604</value></id></referenceID><fileName>NFT_DMS.doc</fileName><docTypes><docTypeID>488</docTypeID></docTypes><fileType>doc</fileType><uploadBy>CLIENT\\G01156119</uploadBy><docDate>{p_DocDate}</docDate><docName>NFT_{p_DocName}</docName><uploadDate>{p_DocDate}</uploadDate><docVer>1</docVer><docSource>CLM</docSource><expDateTime>{p_ExpiryDate}</expDateTime><action>upload</action><docCategory><value>Others</value></docCategory></DMSDocRequest>",
            "Method=POST",
            "TargetFrame=",
            "Resource=0",
            "Referer=",
            "Body="
            "BodyFileName=NFT_DMS.doc",
            LAST); 

以下是我每次尝试收到的错误消息:

尝试1次回复


    <?xml version='1.0' encoding='UTF-8'?>
    <DMSDocResponse>
    <statusCode>-1</statusCode>
    <statusMsg>Exception occured while processing the request: A message body reader for Java class com.barclays.dms.coe.services.rest.ondemand.responses.StoreResult, and Java type class com.barclays.dms.coe.services.rest.ondemand.responses.StoreResult, and MIME media type application/octet-stream was not found</statusMsg>
    <resultSet/>
    </DMSDocResponse>

尝试2和3响应


    <?xml version='1.0' encoding='UTF-8'?>
    <DMSDocResponse>
    <statusCode>-1</statusCode>
    <statusMsg>One Document needs to be attached along with the document upload request.</statusMsg>
    <resultSet/>
    </DMSDocResponse>

请帮助我制定正确的请求,以便我可以正确上传文件。

0 个答案:

没有答案