I need to create a performance test for Nuget repository using Jmeter tool and I need to deploy/upload .nupkg files to the repository however I have a problem with uploading. I receive error number 415 - Unsupported media type. Seems like something wrong with a Content-Type or with multipart/form-data transmission which has to be used for upload. The Jmeter has such option for POST but I have PUT in my case.
The curl below publishes properly
curl -XPUT http://hostname/api/nuget/nuget/ -u login:password -F "package=#/home/nugetFiles/shay-1-test.2.1.0.nupkg"
I have unsuccessfully tried the following - added file path in the Files Upload tab in the HTTP request sampler, added HTTP Header Manager as a child and tried the upload uing several variants with different Content-Types via HTTP Header Manager item.
application/x-nupkg;
application/octet-stream;
multipart/form-data; boundary="6aec860d-8c85-4cea-854e-a051e77873c4";
and Content-Disposition value
Content-Disposition: form-data; name=package; filename=package.nupkg; filename*=utf-8''package.nupkg
HTTP header manager also has X-NuGet-ApiKey value
I also found out that the file should be added to the request body however I do not know how to do it.
Please help.
Just record your upload request.
Copy shay-1-test.2.1.0.nupkg to "bin" folder of your JMeter installation
Configure JMeter for recording. The easiest way is using JMeter Templates feature
from JMeter's main menu choose File -> Templates -> Recording and click "Create"
Open HTTP(S) Test Script Recorder and click "Start"
Execute your CURL request through JMeter's proxu like:
curl -x http://localhost:8888 -XPUT http://hostname/api/nuget/nuget/ -u login:password -F "package=#/home/nugetFiles/shay-1-test.2.1.0.nupkg"
That should be it, the recorded request will live under Thread Group -> Recording Controller.
The root cause it the following - I'm using Jmeter 3.3, the latest released version is 4.0. According to this bug multipart/form-data transmission which is necessary for NuGet client - does not work in Jmeter for PUT method.
I have checked a stable trunk Jmeter version (apache-jmeter-r1831500.zip) has taken from here and was able to deploy Nuget package.
As a workaround it's possible to create a test via OS Process Sampler using bash commands.
Thanks everybody for help.
Related
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.
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
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:
Finished my performance test and need to make visible those test reports in my JIRA cases. Is there any efficient way to verify my JMeter test results in JIRA ?
Please add some screenshots for my reference if there is any methods to be followed to achieve this requirement.
Thanks in advance
As far as I'm aware JIRA has a set of REST APIs and looking into How to add an attachment to a JIRA issue using REST API article you should be able to upload JMeter test result into JIRA using the following command:
curl -D- -u {username}:{password} -X POST -H "X-Atlassian-Token: nocheck" -F "file=#{path/to/file}" http://{base-url}/rest/api/2/issue/{issue-key}/attachments
You can upload results file even from JMeter test itself, i.e.
Add the next line to user.properties file
jmeter.save.saveservice.autoflush=true
Add tearDown Thread Group to your Test Plan
Add HTTP Authorization Manager to the tear Down Thread Group and put your JIRA credentials there
Add HTTP Header Manager and configure it to send X-Atlassian-Token header with the value of nocheck
Add HTTP Request sampler and configure it as follows:
Protocol: your JIRA installation protocol, most likely https
Host: your JIRA installation IP address or hostname
Method: POST
Path: /rest/api/2/issue/issue-key/attachments
Tick Use multipart/form-data for POST box
In the "File Upload" tab provide full or relative path to your .jtl results file and its MIME type. Keep "Parameter Name" value as file
See Performance Testing: Upload and Download Scenarios with Apache JMeter article for more information on performing file uploads using JMeter.
I am working on upload file module that works on internet explorer only and it requires following browser setting mandatory:
"Include local directory path when uploading files to server" should be enabled.
A failure message "Unable to upload file" displays when we do not make required setting in browser while manual attempt else it works fine.
Now when I am trying to record the scenario in JMeter, getting same error message even I made required browser settings.
Note: Additionally, I tried to include these calls by copying from browser tools and paste it in JMeter transaction but get the same result in response.
Have any one experience the same or can help me out?
Thanks,
Nitin
Few things to consider:
Make sure that you use Java implementation of HTTP Request
Make sure that "Use multipart/form-data for POST" is checked
Make sure that you provide a file within "Send Files With the Request" field providing correct path, parameter name and mime-type
If all above has already been applied and you still experience problems I would recommend to capture the data being sent by Internet Explorer with a sniffer (Fiddler, Wireshark, etc.) and compare it to data, being sent by JMeter. They must be the same. If they aren't - you'll need to customize it using HTTP Header Manager, HTTP Cookie Manager, etc. If JMeter is not flexible enough to set all the required parameters via GUI, i.e. still tries to send full path of file instead of just filename or vice versa, you can always go deeper and manually build multi-part post request via Java Request Sampler (see SleepTest and JavaTest source code for details) or via Beanshell which is 100% compatible with Java syntax but may be harder to debug due to it's script nature.
Path to SleepTest and JavaTest files is follows:
/src/protocol/java/org/apache/jmeter/protocol/java/test/JavaTest.java
/src/protocol/java/org/apache/jmeter/protocol/java/test/SleepTest.java
JMeter sources are available from JMeter download page
Steps to upload the image using jmeter:
locate the image in bin folder Select Post method and check the "Use
multipart/form-data for POST" in HTTP Request
Provide details of Send files With the Request in HTTP Request
Record the Upload scenario and stop button in Jmeter (Image wouldn't upload while recording in Jmeter)
Now before running the script, Go to upload response and give the full path of image in "Send files with request field"
Now Run the script. You can able to see the image