Highlighted
Super Contributor.. Super Contributor..
Super Contributor..
4892 views

How to upload multiple files through web_custom_request

Hi,

I want to upload multiple files (9 files at once)through web_custom_request. Please give me syntax.

web_custom_request("xxx",
  "URL=http://xxxx
  "Method=POST",
  "Resource=0",
  "RecContentType=text/plain",
  "Referer=xxxx",
  "Snapshot=t17.inf",
  "Mode=HTML",
  "EncType=multipart/form-data; boundary=---------------------------7e09d3113082c",
  "BodyBinary=-----------------------------7e09d3113082c--",

Regards,

KHB

 

0 Likes
5 Replies
Highlighted
Frequent Contributor.
Frequent Contributor.

Re: How to upload multiple files through web_custom_request

Hello, 

If you mean upload 9 files concurrently, concurrent group can be used here:

    web_concurrent_start("concurrent_upload", NULL);
    web_custom_request("upload1", "URL=http://xxxx", "Method=POST", "BodyFileName=1.txt", LAST);
    web_custom_request("upload2", "URL=http://xxxx", "Method=POST", "BodyFileName=2.txt", LAST);

...

    web_custom_request("upload9", "URL=http://xxxx", "Method=POST", "BodyFileName=9.txt", LAST);
    web_concurrent_end(NULL);

For web_custom_request, it just support one "BodyFileName" parameter and  send a Http(s) request, but the request "body" is fully customer defined, you can prepare any thing into a buffer and send that buffer as a Raw Body with  web_custom_request:

web_custom_request("upload1", "URL=http://xxxx", "Method=POST", RAW_BODY_START, pBuf, strlen(pBuf) , RAW_BODY_END,LAST);

Regards,

Bingle(LoadRunner R&D)

Highlighted
Super Contributor.. Super Contributor..
Super Contributor..

Re: How to upload multiple files through web_custom_request

Hi,

I want upload 9 .xlsx files as import to my url. so the below line should be added

    web_concurrent_start("concurrent_upload", NULL);
    web_custom_request("upload1", "URL=http://xxxx", "Method=POST", "BodyFileName=1.txt", LAST);
    web_custom_request("upload2", "URL=http://xxxx", "Method=POST", "BodyFileName=2.txt", LAST);

...

    web_custom_request("upload9", "URL=http://xxxx", "Method=POST", "BodyFileName=9.txt", LAST);
    web_concurrent_end(NULL);

after  or within

web_custom_request("xxx",
  "URL=http://xxxx
  "Method=POST",
  "Resource=0",
  "RecContentType=text/plain",
  "Referer=xxxx",
  "Snapshot=t17.inf",
  "Mode=HTML",
  "EncType=multipart/form-data; boundary=---------------------------7e09d3113082c",
  "BodyBinary=-----------------------------7e09d3113082c--",

LAST);

Please clarify me

Regards,

KHB

0 Likes
Highlighted
Frequent Contributor.
Frequent Contributor.

Re: How to upload multiple files through web_custom_request

Hello,

I suppose you're using HTML Forms to upload files, so why not using the web_submit_form or web_submit_data?

sample: 

    web_submit_data("upload_files", 
        "Action=http://xxx", 
        "Method=POST", 
        "EncType=multipart/form-data", 
        "TargetFrame=",
        "Mode=HTML", 
        ITEMDATA, 
        "Name=datafile1", "Value=1.txt", "File=Yes", ENDITEM, 
        "Name=datafile2", "Value=2.txt", "File=Yes", ENDITEM, 

        "Name=datafile9", "Value=9.txt", "File=Yes", ENDITEM, 
        LAST);

To use the web_custom_request, that means you have to prepare the payload by your self. 

Regards,

Bingle

 

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

Re: How to upload multiple files through web_custom_request

Hi,

Use 'BodyFilePath' option in custom request to upload files using web_custom_request.  Also please check the Body Binary in th page in browser using 'Developer Tools' and check whether any thing is missing in the Body Binary

web_custom_request("Mercury", "URL=http://…", "Method=PUT", "Resource=1", "RecContentType=text/plain", "Referer=", "BodyFilePath=fileName", LAST);

 

Regards,

Raghul

0 Likes
Highlighted
Absent Member.
Absent Member.

Re: How to upload multiple files through web_custom_request

Hi

can someone help me with solution "to send Json Payload along with PDF file."

MY request should contain 2 parts, 

part 1 - metadata - json payload 

Part 2 - ,metadata - with specific pdf file.

 

I added .json and .pdf file in the script extra files. but I could not submit successful request to origin server.

Regards

G

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.