Highlighted
Trusted Contributor.
Trusted Contributor.
3163 views

How to submit Request Payload in Vugen

Hi Team, we are unable to uplaod any file type in our application. It's generated the script with web custom request and BODY generated. 

below the custome request generating. Can some one help me.

web_custom_request("97694", 
        "URL=https://{URL}/otmmapi/v4/jobs/imports/{jpob}", 
        "Method=PUT", 
        "TargetFrame=", 
        "Resource=0", 
        "RecContentType=application/json", 
        "Referer=https://{url}/", 
        "Snapshot=t21.inf", 
        "Mode=HTML", 
/*        "Body=-----------------------------7e227f20391016\r\nContent-Disposition: form-data; name=\"job_name\"\r\n\r\nperf\r\n-----------------------------7e227f20391016\r\nContent-Disposition: form-data; name=\"parent_folder_id\"\r\n\r\nfeaab744ba3806215ebd84db89488617b5fddff0\r\n-----------------------------7e227f20391016\r\nContent-Disposition: form-data; name=\"import_job_id\"\r\n\r\n97694\r\n-----------------------------7e227f20391016\r\nContent-Disposition: form-data; name=\"manifest\"; filename=\""
        "blob\"\r\nContent-Type: application/json; charset=UTF-8\r\n\r\n{\"upload_manifest\":{\"master_files\":[{\"file\":{\"file_name\":\"LD_DAM_Duplicates-Demo-20180501 (1).mp4\",\"file_type\":\"video/mp4\"}}]}}\r\n-----------------------------7e227f20391016\r\nContent-Disposition: form-data; name=\"asset_representation\"; filename=\"blob\"\r\nContent-Type: application/json; charset=UTF-8\r\n\r\n{\"asset_resource\":{\"asset\":{\"metadata\":{\"metadata_element_list\":[{\"id\":\"KFG.FIELD.CREATIVE_AGENCY\""
        ",\"type\":\"com.artesia.metadata.MetadataField\",\"value\":{\"value\":{\"type\":\"string\",\"value\":\"KF\"}}},{\"id\":\"KFG.FIELD.CREATIVE_AGENCY_RESTRICTED\",\"type\":\"com.artesia.metadata.MetadataField\",\"value\":{\"value\":{\"type\":\"string\",\"value\":\"KF\"}}}]},\"metadata_model_id\":\"KFG.MODEL.PRODUCT_MEDIA_ASSET\",\"security_policy_list\":[{\"id\":21}]}}}\r\n-----------------------------7e227f20391016\r\nContent-Disposition: form-data; name=\"file_name\"\r\n\r\n"
        "LD_DAM_Duplicates-Demo-20180501 (1).mp4\r\n-----------------------------7e227f20391016--\r\n", */
        LAST);

Tried below optiona aslo but still not working,

 web_submit_data("97686",
        "Action=https://test.kf.cloud.opentext.com/otmmapi/v4/jobs/imports/{import_job_id}",
        "Method=POST",
    //    "EncType=multipart/form-data",
        "Resource=0",
        "RecContentType=application/json",
        "Referer=https://test.kf.cloud.opentext.com/",
        "Snapshot=t17.inf",
        "Mode=HTML",
        "EncType=multipart/form-data",
         ITEMDATA,
        "Name=job_name", "Value= ", ENDITEM,
        "Name=parent_folder_id","Value=feaab744ba3806215ebd84db89488617b5fddff0",ENDITEM, 
        "Name=import_job_id", "Value={import_job_id}",ENDITEM, 
        "Name=manifest","Value=",ENDITEM,
        "Name=filename", "Value=blob", ENDITEM, 
//        "ContentType= application/json",
//        "filename=bolb","Value=",ENDITEM,
        "Name=asset_representation","Value=",ENDITEM,
        "Name=file_name","Value=3663602001751_06i_fr.jpg",ENDITEM,
//        "ContentType= application/json",    
//        "Filename='blob", "Value= ",ENDITEM,
//        "Name=file_name","Value=C:/Users/machil01/Downloads/3663602001751_06i_fr.jpg",ENDITEM, 
//      "Name=metadata_element_list","Value=KFG.FIELD.CREATIVE_AGENCY,KFG.FIELD.CREATIVE_AGENCY_RESTRICTED",
//        ENDITEM,
        LAST);

 

 

Thanks,

Laxmi

13 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

------WebKitFormBoundaryHkSuvPO0atyAlJlB is just body parts delimiter generated by client. It is not correlation and you can just use the same value in replay. Probably instead of "-----------------------------7e227f20391016". Just don't forget to add 2 dashes at the end (last delimiter): ------WebKitFormBoundaryHkSuvPO0atyAlJlB--
0 Likes
Highlighted
Contributor.
Contributor.

Hi 

I faced the same issue as you did and figured out a solution for myself.

You are trying to upload a file so first of all you don't need to write a custom request for it.

Here is how I solved it. ------

You have to use web_submit_data function and you have to use EncType= multipart/form-data. Using multipart form data, what it does is that it seperates the Item Data in your request with a random boundary(the type of boundary that you saw while seeing the recorded request as Webkitboundary--something something).

In my case there was "blob" recorded and its the same in your case too. So if you are able to sent the blob part of the item data properly then you are good to go and the rest of the part of the request you have to manage yourself.

blob part can be sent by writing a text file in the script itself and then sending it in the itemdata with application/json type.

the request will look like

 

web_submit_data("submitdata",

                                    "Action=https://site.com",

                                    "Method=POST",

                                    "EncType=multipart/form-data",

                                    "Referer=https://something.com",

                                    "Snapshot=t1.inf",

                                    "Mode=HTML",

                                    ITEMDATA,

                                   "Name=document", "Value=textfile.txt", "File= Yes", "ContentType=application/json",ENDITEM,

                                   "Name=file", "Value=abc.docx", "File-Yes", "ContentType=application/vnd.openxmlformars-officedocument.wordprocessingml.document",ENDITEM,

                                 LAST);

Now here the textfile.txt containg the text ------- "{"upload_manifest":{"master_files":[{"file":{"file_name":"LD_DAM_Duplicates-Demo-20180501 (1).mp4","file_type":"video/mp4"}}]}} "

which is passes as a file so it the above text has some dynamic valuesthen you have to correlate them and pass it in the file and if the values change for each iteration then you need to generate a new file everytime and remove that file everytime and for that you need to put some file operations before this request.

You can always Connect to me if you have any queries.

Thanks

Nivesh

 

 

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.