how to send the file with Http request in jmeter - jmeter

Please find the below post data for the request to send the file to application,I have tried but not uploading the file to application and even I couldn't see any error for that request in jmeter,Please hel me.
{"requests":[{"event":[{"controller_id":"${codDocID}","event":"AddFileMDSubmit","id":"createFile","param":[{"name":"Path","value":"/Root/AttachmentFolder"},{"name":"Action","value":"CreateFile"}]}],"data":[{"scope":[{"path":"/Root","changed":""},{"path":"/Root/EnableDisableActionMenu","changed":""},{"path":"/Root/$System","changed":""},{"path":"/Root/$ThingHeader","changed":""},{"path":"/Root/UIState","changed":""},{"path":"/Root/ZSchdleDateTime_200486e20a2d29145d81bba1f204e795","changed":""},{"path":"/Root/zFeederRelevant","changed":""},{"path":"/Root/$UISwitch","changed":""},{"path":"/Root/ToCoreBO","changed":""},{"path":"/Root/LaunchPreviewPDFStruct","changed":""},{"path":"/Root/ScopingIndicator","changed":""},{"path":"/Root/HybrisIntegration","changed":""},{"path":"/Root/UtilitiesIndExt","changed":""},{"path":"/Root/TP_ResolutionDueDateTime/content","changed":""},{"path":"/Root/TP_ResolutionDueDateTime","changed":""},{"path":"/Root/TP_CompletionDue/content","changed":""},{"path":"/Root/TP_CompletionDue","changed":""},{"path":"/Root/ExternalSalesOrderDocumentReference","changed":""},{"path":"/Root/EmailFeeder/InteractionAttachments","changed":"","columns":[{"path":"SelectedIndicator","changed":"X"},{"path":"NodeID","changed":"X"}]},{"path":"/Root/Customer_BusinessPartner/Structure","changed":""},{"path":"/Root/Customer_BusinessPartner","changed":""},{"path":"/Root/PricingTerms","changed":""},{"path":"/Root/CpTotalCustAmount_0479727343a243b5b39e3b8dd38054aa","changed":""},{"path":"/Root/CpTotalReclAmount_bff3d7be2aec457786179c6bc6f0e83b","changed":""},{"path":"/Root/CpTotalReclUponRet_55e401c0e848418fb07a3b71c480125e","changed":""},{"path":"/Root/CpTotalCustInDest_ebcecb07263e4d81b8ad6a2105b4ce16","changed":""},{"path":"/Root/CpTotalReclInDest_73eb1b917ee34f2db12f1d491d0e642e","changed":""},{"path":"/Root/CpTotalCustUponRet_4d69521c51ac4e7b96601ad2402a599e","changed":""},{"path":"/Root/ZK_ApprovedAmount_75f8a8768f4708ab080050e720617a13","changed":""},{"path":"/Root/CreatedOn","changed":""},{"path":"/Root/ChangedOn","changed":""},{"path":"/Root/TP_InitialReceipt/content","changed":""},{"path":"/Root/TP_InitialReceipt","changed":""},{"path":"/Root/TP_InitialResponseDue/content","changed":""},{"path":"/Root/TP_InitialResponseDue","changed":""},{"path":"/Root/TP_InitialResponse/content","changed":""},{"path":"/Root/TP_InitialResponse","changed":""},{"path":"/Root/TP_Completion/content","changed":""},{"path":"/Root/TP_Completion","changed":""},{"path":"/Root/TP_ResponseByProcessorDue/content","changed":""},{"path":"/Root/TP_ResponseByProcessorDue","changed":""},{"path":"/Root/CpApprovalAchievedDateTime_e5a9db72014e12473aa7b19f1b100ecc","changed":""},{"path":"/Root/SearchResults","changed":"","columns":[{"path":"Index","changed":"X"},{"path":"ArticleIcon","changed":"X"},{"path":"ExternalKnowledgeBaseArticleURI","changed":"X"},{"path":"ExternalKnowledgeBaseCode","changed":"X"},{"path":"ExternalKnowledgeBaseArticleID","changed":"X"},{"path":"Author","changed":"X"},{"path":"Date","changed":"X"},{"path":"ExternalKnowledgeBaseArticleDescription","changed":"X"},{"path":"ExternalKnowledgeBaseArticleDescription1","changed":"X"},{"path":"ExternalKnowledgeBaseArticleShortURI","changed":"X"},{"path":"ExternalKnowledgeBaseArticleURI1","changed":"X"},{"path":"JAMUri","changed":"X"},{"path":"JAMViewsCount","changed":"X"},{"path":"NodeID","changed":"X"},{"path":"Note","changed":"X"}]},{"path":"/Root/From_KB_EC/DetailView","changed":""},{"path":"/Root/From_KB_EC","changed":""},{"path":"/Root/SimilarTickets","changed":"","columns":[{"path":"Index","changed":"X"},{"path":"Name","changed":"X"},{"path":"ID","changed":"X"},{"path":"UUID","changed":"X"},{"path":"#RowCount","changed":"X"},{"path":"CustomerFormattedName","changed":"X"},{"path":"ReporterName","changed":"X"},{"path":"ServiceRequestUserLifeCycleStatusCode","changed":"X"},{"path":"CreationDateTime","changed":"X"},{"path":"ProductID","changed":"X"}]},{"path":"/Root/SimilarTicket_UIData","changed":""},{"path":"/Root/TimeEntry_MergeTimeItem","changed":""},{"path":"/Root/ChildServiceRequstModificationUserSelected","changed":""},{"path":"/Root/TP_ResolvedOnDateTime","changed":""},{"path":"/Root/TP_OnSiteArrivalDateTime","changed":""},{"path":"/Root/TP_OnSiteArrivalDueDateTime","changed":""},{"path":"/Root/TP_RequestedFulfillmentEndDateTime","changed":""},{"path":"/Root/TP_RequestedFulfillmentStartDateTime","changed":""},{"path":"/Root/TP_Escalation","changed":""},{"path":"/Root/TP_ResponseByCustomer","changed":""},{"path":"/Root/TP_ResponseByProcessor","changed":""},{"path":"/Root/WarrantyReferenceDateTime","changed":""},{"path":"/Root/StickyNoteInteractor","changed":""},{"path":"/Root/PricingTerms/DateTime","changed":""},{"path":"/Root/Groups_Recommended","changed":""},{"path":"/Root/LoggedUserDetails","changed":""},{"path":"/Root/zAWS_Features","changed":""}],"id":"${codSeodAgentID}"},{"id":"${codDocID}","flat_data":[{"key_path":"/Root/AttachmentFolder/AddParams/TypeCode","value":"${typeCodeVal}","aspect":"C"},{"key_path":"/Root/AttachmentFolder/OutputRelevant","value":"","aspect":"C"},{"key_path":"/Root/AttachmentFolder/AddParams/fileName","value":"${fileName}","aspect":"C"},{"key_path":"/Root/AttachmentFolder/AddParams/Title","value":"${fileName}","aspect":"C"},{"key_path":"/Root/AttachmentFolder/AddParams/fileSize","value":"190","aspect":"C"},{"key_path":"/Root/AttachmentFolder/AddParams/content","value":"id%3D00163E2F045E1EE88BD561E26708DE0E","aspect":"C"}]}]}]}

Store your file in "bin" folder of your JMeter installation as i.e. data.json
Switch to "File Upload" tab of the HTTP Request sampler and configure it like:
If you're uncertain regarding what to put in the "Parameter Name" field you can just record your request using JMeter's HTTP(S) Test Script Recorder via web browser, just make sure that the data.json file is present in JMeter's "bin" folder. Check out Recording File Uploads with JMeter guide for more details.

Related

I get Bad Request error for adding form-data as Jmeter body

I'm not sure how to add what the API Documentation says (see screenshot below) in the JMETER body:
I tried doing the following:
However, I get the following error:
Please does anyone have a solution?
Shouldn't the taxpayer be a single object (i.e. a JSON Object) rather than separate parameters?
Your HTTP Header Manager doesn't make any sense, if you tick Use multipart/form-data box JMeter automatically sets the relevant Content-Type header
If you're able to successfully execute the request in browser via Try it out button you can just record the file upload request using JMeter's HTTP(S) Test Script Recorder, just make sure to copy the file to JMeter's "bin" folder before "trying it out"

Uploaded xml file content is not showing in the request body in Jmeter and the request fails

Uploaded xml file content is not showing in the request body in Jmeter.
Jmeter version: 5.4.1
We have .xml file upload scenario, recorded using Blazemeter. After downloading the recorded script to Jmeter, necessary token co-relation and extracting required values using RegEx been done. Then tried to run the script, it fails at the upload request.
Recorded script doesn't have "FileUpload" tab with location. I updated with the file location too. As suggested in other queries/blogs, observed the traffic using other tools to see if any header value is missing and incorporated that too still it fails at upload request.
Observed that, the request body shows file content in other tools where as in Jmeter the file content is not shown.
ZAP tool request body:
Jmeter:
Also, the headers shows in green color, not sure if any specific reason to look at it under view results tree - http request.
Try re-recording the request (it may be a single request only, enable proxy just for it) using JMeter's HTTP(S) Test Script Recorder, it should generate the HTTP Request sampler with "Files upload" section and Use multipart/form-data for POST box checked.
Just make sure to copy the XML file(s) you're uploading to "bin" folder of your JMeter installation prior to uploading the file, this way JMeter will be able to properly "catch" the request.
More information: Recording File Uploads with JMeter

Tar.gz files are not extarcting in Google cloud bucket using Jmeter

I am trying to upload tar.gz files into google cloud bucket using jmeter. Here i am using File management service, GCS & Jmeter.
Execution flow.
1. Using get Request i am hitting FMS.In response I'll get response message. this response contains the URL to upload the file to GCS.
2. Now the file SJ311.tar.gz file is uploaded in the folder iviu/SJ311 folder in GCS.
3. In GCS cloud function is written a code which will extract the .gz file & all .csv files should be extracted successfully.
Issue : through POSTMAN i am able to do this i.e. file is uploaded & it is decompressing the tar file but using jmeter file is uploaded successfully but its not extracting/decompressing.
If you're able to send the request using Postman and see that JMeter behaves differently than it means that you're not sending the same request using JMeter.
Most probably this is due to missing or incorrectly defined HTTP Header so make sure to compare each and every detail of the request and given you send the same requests you should get the same behaviour/response.
Going forward if something is working in Postman and not working in JMeter you can just record the relevant request using JMeter's HTTP(S) Test Script Recorder, just configure Postman to use JMeter as the proxy and run your request, JMeter will capture it and properly build the HTTP Request sampler, add HTTP Header Manager, etc.
Just remember to copy the file(s) you will be uploading to the "bin" folder of your JMeter installation prior to recording, otherwise JMeter will not be able to capture the request.
Solution to the above question is, under File upload section-> under Parameter name field i added DOM attribute or webelement value for the "upload file" button which is present in Google cloud storage screen.
Now after removing that parameter value, file is getting uploaded successfully.
If we add the attribute value, file will get uploaded successfully but it will be corrupted.

Sending parameter with POST requests with Web-kit Form-Data with J Meter

Trying to post a data within WebKitFormBoundary in JMeter 5.2, but getting code:406 message:Not Acceptable.
My parsed data is:
------WebKitFormBoundarycBh5zHV8PGTFb5LA
Content-Disposition: form-data; name="heading"; filename="blob"
Content-Type: application/json
{"headers":[{"name":"Host","value":"https://localhost:443/Country"},
{"name":"Ocp-Apim-Subscription-Key","value":"8dc88db306d04e6d69c553499b74c5sw","secret":true}],
"httpMethod":"GET","host":"https://localhost:443/Country",
"path":"Countries/api/Countries?versionQuery=Countries_V1","scheme":"https"}
------WebKitFormBoundarycBh5zHV8PGTFb5LA--
I am trying post the above data from Jmeter http request in two ways:
Method 1:
Method 2:
Snap of the browser details:
Request Header:
Form Data:
I have handled the X-Request-Verification-Token and RequestVerificationToken, which is working fine. But I am getting
Response message:
Embedded resource download error:https://https://localhost:443/
code:406 message:Not Acceptable
The easiest way of building file upload events in JMeter is simply recording them using JMeter's HTTP(S) Test Script Recorder, just make sure to copy the file you're uploading to the "bin" folder of your JMeter installation, this way JMeter will be able to intercept the request and properly build the HTTP Request sampler.
Check out Recording File Uploads with JMeter for more details if needed.
If you're still looking for a manual way of implementing your request the easiest option would be storing your JSON payload into blob file in the "bin" folder of your JMeter installation and configuring the "File Upload" tab of the HTTP Request sampler to look like:
You should see something like this in the View Results Tree listener:

Test download a file using Jmeter (the http response has download link)

Test 'download a file using Jmeter': On the web page, there is a button 'download' and clicking it downloads the file with .zip extension. When observed under Network tab of Developer tool (F12)>there are two requests: 1 is the application request which gives the response with link (aws-S3...) (if i copy paste this link, can download the zip file) and 2nd request shows the aws-S3..link. When need to perform this download performance testing with 100 users, how to configure in Jmeter. Please guide. below thing have been tried:
Record a script>it records the first request (not the 2nd request of network tab as mentioned above)
When run the script> this shows 200 code with response message as aws-S3..link
Tried Save response to file listener> nothing has been downloaded.
Extract the download link from 1st response using i.e. Regular Expression Extractor
Add put the JMeter Variable generated by the Regular Expression Extractor into "Path" input of the HTTP Request 2
Add Save Responses to a file listener as a child of the HTTP Request 2
See Performance Testing: Upload and Download Scenarios with Apache JMeter article for more information on simulating file upload/download events in JMeter web tests.

Resources