I'm trying to send a csv file as a request in body.
It's working fine for me in Postman. But I'm getting the below error in Jmeter.
{
"id":32,
"deleted":null,
"uuid":"f5cec747-4794-4e54-9c4b-58da61f30921",
"status":"Error",
"csvFileName":"",
"unsuccessfulRecords":[
"['Not Applicable', '{\\'csvFile\\': [ErrorDetail(string=\\'The submitted data was not a file. Check the encoding type on the form.\\', code=\\'invalid\\')], \\'assets\\': [ErrorDetail(string=\\'Expected a list of items but got type \"str\".\\', code=\\'not_a_list\\')]}']"
],
"successfulRecordsCount":0,
"duplicateRecordsCount":0,
"createdBy":"user",
"createdAt":"2022-12-06T09:58:51.285524Z",
"modifiedAt":"2022-12-06T09:58:51.285538Z",
"idAllowdAt":"2022-12-06T09:58:51.285538Z",
"idAllowListType":1
}
Below is the request i'm sending as part of Body Data. The REST Api accept these parameters, and afer that it imports the CSV file:
{
"csvFile": "${__FileToString(D:/Users/anabeel/Downloads/Demo/Demo.csv,,)}",
"allowlistTypeId": "1",
"createdBy": "user",
"assets": "['asset1', 'asset2']",
"uuid": "${requestIndex}",
"tags": "{'Platform Family':[{'abc123':'LinuxOS System'}]}",
"tenantId": "abc456"
}
Content-type: application/json
It seems I'm not importing the csv file the right way. Can someone please help me as I dont have much experience working with Jmeter. I also tried using CSV Data Set Config, but it didn't worked for me.
If your request "working fine for me in Postman" you can just record it using JMeter's HTTP(S) Test Script Recorder.
Configure JMeter for recording, the easiest option is going for Recording Template
Import JMeter's certificate to Postman
Configure Postman to use JMeter as the proxy
Copy your CSV file to bin folder of your JMeter installation
Run your request in Postman
JMeter will generate proper HTTP Request sampler and HTTP Header Manager
Parameterize the path to the CSV file if needed
Your JMeter request should be working fine now
More information: JMeter Performance Testing: Upload and Download Scenarios
Related
I am trying to upload photo via Jmeter, below is the sample request:
URL: https://domain/.../signedresources/604a9230-..../resumable?region=US
Method: PUT
Headers:
Content-Type - image/jpeg, image/jpeg
Session-Id - 884b03...
Content-Range - bytes 0-73580/73581
Content-Length - 73581
In File Upload tab of Jmeter I have checked: Use Multipart/form-data option
File Path: /Users/sujata.../Downloads/fish.jpeg
Parameter Name: file_upload[]
MIME type: image/jpeg
Now, this request works fine when executed via Postman, and in Postman Content-Length 73581 header is not passed. The file size in bytes is 73581. However while running this request via jmeter Content-Length - 73581 header is automatically added and everytime the value is different, which is ending up with below error:
{"reason":"Chunk-Length mismatch (found: 73800, required:73581)"}
Is there any way to compute the content-length of file which we are going to upload and pass that value in the header?
I also tried explicitely mentioning Content-Length - 73581 in header but still it is not taking this valued and somehow some new value is computed and mismatch error is shown.
Is there any way to bypass this content-length computation by jmeter, or overwrite?
PUT-Request-Jmeter
Content-Type_header_added_by_jmeter
Content-Length header stands for the number of bytes in the request body. The request body begins right after the Headers. So if you're uploading just one file and there are no dynamic parts of the request - it should be the same every time you execute the request. However for multipart requests you have the boundary which is random and its length may vary, that explains the eventual differences.
It might be the case Postman sends the file in "raw" mode, i.e. not multipart. In this case you will need to untick Use multipart/form-data box in the HTTP Request sampler.
Going forward if you're able to successfully run the request using Postman you can just record it with JMeter's HTTP(S) Test Script Recorder
Start JMeter's HTTP(S) Test Script Recorder
Import JMeter's certificate into Postman
Configure Postman to use JMeter as the proxy
Copy the file you will be uploading to the "bin" folder of your JMeter installation
Run your request in Postman
That's it, now you should have appropriate JMeter configuration for the file upload.
More information: How to Convert Your Postman API Tests to JMeter for Scaling
I have a jmeter scenario where I need to upload a txt file of different size . To upload the file in jmeter , we enable multipart and request is of PUT type.
I am also getting put body , which is creating issue in my log files in the backend . Posting a sample request body . Is there any way where we can just send data without any data showing up under put data .
According to your screenshot you're trying to upload a file to http://www.csm-testcenter.org/test page, the page assumes HTTP POST method, not PUT.
If you're uncertain regarding proper JMeter configuration when it comes to uploading files be informed that you can just record the file upload event using your favourite browser (or another application) and JMeter's HTTP(S) Test Script Recorder. All you need to do is to copy the file to "bin" folder of your JMeter installation, this way JMeter will be able to properly capture the request and generate the relevant HTTP Request sampler and HTTP Header Manager.
More information: Recording File Uploads with JMeter
I've got a URL with following format, I'm not quite sure how to generate this URL after "# " using an HTTP request using Jmeter, Any pointers would be highly appreciated.
${url}}/a/?case_type_category=cases#/case/list?cf={"case_type_category":"cases","case_manager":[2]}
Just put everything into "Path" field of the HTTP Request sampler and JMeter will parse it
You don't need to construct URLs manually, they can be recorded using HTTP(S) Test Script Recorder or JMeter Chrome Extension
See URL.hash MDN documentation chapter for more details
I am having an issue with my open feign client uploading documents to a backend API. I have been able to upload a document successfully using Postman, but when I use the exact same settings on my open feign client, the uploaded pdf becomes corrupted and cannot be opened.
#RequestLine("POST /url")
#Headers({
"Content-type: x-www-form-urlencoded",
})
DocumentUpload uploadDocument(#Param("string") String string, #Param("file") File file);
The url, content type, and parameters are all the same in Postman, and as far as I can tell, there are no other settings that I am missing. Has anyone had similar issues or have ideas on what to troubleshoot? Of note, I have tried different content types (eg multipart/form-data) and they fail similarly.
I'm new to Apache NiFi, and I developed an application to send JSON data to a NiFi endpoint via HTTP POST request.
In Apache NiFi, I have a HandleHTTPRequest processor connected to a PutFile processor then a HandleHTTPResponse processor. I've also tried using a LogAttribute processor. The response code and HTTP message from the NiFi web service is working properly, but I'm trying to make sure my JSON payload is being sent properly. Post is enabled in the HTTPRequest handler. Yet, the only files it's generating are blank and 0kb in size. Any ideas?
Based on the comments above the conclusion is that there was no problem on the side of Nifi.
It's definitely an issue with the Java code, I used postman again after changing some local firewall configurations and it successfully logs any POST requests that are sent to it and puts it in a file
The key step towards resolving the issue was trying to connect with something like Postman as #Binary Nerd and #Brian Bende suggested.