JMeter testing for the url which contains # as path param - api

I have REST API which takes the username as a path parameter like this - app/users/{username}.
As per the business requirement, the username can be an email address as well.
Application is developed and we can test using postman, curl etc., by encoding the URL. But when we use JMeter to test the same API,
We are not able to send the encoded URL using JMeter. To demonstrate the problem, I created a webhook site(https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter%40jmeter)
and requested as below.
"GET https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter%40jmeter"
This resulted in a webhook as below
"https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter#jmeter"
But we want the output like below which we could accomplish by postman or curl.
curl --location --request GET 'https://webhook.site/3c84998f-ecbb-4cee-a1e1-7c7ae059a209/testjmeter%40jmeter'
Please help how I need to prepare my JMeter script which produce the same output as above (in curl)

I cannot reproduce your issue using latest JMeter 5.4
Not sure what does your "webhook" do, however in a sniffer tool like Wireshark request paths are exactly the same for curl and JMeter and no %40 doesn't get decoded into #
If you're capable of sending your request successfully via curl or postman you should be able to record it using HTTP(S) Test Script Recorder - this way you will get appropriate JMeter configuration.

Related

Jmeter showing response code as 300 in response

I am working in a desktop application which contains API as well.
So when I try to hit the API using Jmeter with the local server name as localhost. I am getting the response as below
Response code:300
Response message:MULTIPLE CHOICES
Response data:
{"succeed": false, "error_message": "No data JSON received!"}
Even I tried with the Content-Type as application/json and multipart/form-data, but not worked.
Note: When I try to hit the same API using Postman, I got the 200 status.
If you're able to successfully execute the request using Postman you should be able to do this using JMeter as well. We cannot state what's wrong without seeing your Postman and JMeter configurations, just make sure that everything is the same:
request URL
request bosy
request headers
etc.
If you will send the same request - you will get the same response.
Be aware that you can just record the request from Postman using JMeter
Start JMeter's HTTP(S) Test Script Recorder
If you're using HTTPS protocol - import JMeter's certificate into Postman
Configure Postman to use JMeter as the proxy
Run your request in Postman
JMeter will capture the request and generate relevant HTTP Request sampler and HTTP Header Manager
More information: How to Convert Your Postman API Tests to JMeter for Scaling

Same HTTPS request works in Postman but gives 400 Bad Request in JMeter

I think I tried all the possible combinations of headers and body for my POST request in JMeter but is giving me 400 Bad Request saying that the languagePairID parameter from the body is invalid even tho it is exactly same as in Postman.
My headers:
And the request:
Meanwhile in Postman in works perfectly fine:
I tried checking and unchecking the multipart/form-data and browser-compatible headers, but nothing seems to help. I read that using Wireshark might be useful in such cases but I think for this one is not possible as it is HTTPS. I will be very grateful for any advice.
Uncheck "Use mutipart/form-data"
Remove everything from the "Body Data" tab
Switch to "Parameters" tab and put your parameters there:
Going forward be informed that you can easily convert your Postman script into JMeter:
Start JMeter's HTTP(S) Test Script Recorder
Import JMeter's certificate to Postman
Configure Postman to use JMeter as the proxy
Run your request in Postman
JMeter will capture the request and generate relevant HTTP Request sampler and HTTP Header Manager
More information: How to Convert Your Postman API Tests to JMeter for Scaling

Bad Request : 400, when generating bearer token for OAuth2.0

I have setup an api in jmeter which will generate the bearer token for OAuth 2.0. When checking the request body in view result tree listener, seems like jmeter is not parsing the -Client Secret key.
request making
View Result tree - Request body
Response - 400
Please try the below,
Tried it on postman, (working fine)
Now from JMeter, (working fine)
I guess you missed the checkboxes (URL Encode?) in the request parameters in the Jmeter section
HTTP Status 400 means "bad request", one of your request parameters is not correct, like URL or request data or request headers, cross check them with browser/postman
If you're able to successfully execute the request using Postman you can just record the request from Postman using JMeter's HTTP(S) Test Script Recorder
Start JMeter proxy server
Configure Postman to use JMeter as the proxy
Run your request in Postman
JMeter will capture the request and generate appropriate HTTP Request sampler and HTTP Header Manager
More information: How to Convert Your Postman API Tests to JMeter for Scaling

Karate API Tests - Post Request failing but works using Jmeter

I am trying to implement testing POST request for my APIs using KARATE, but getting 403 - expected csrf token not found.
However, I am able to perform POST Request using Jmeter - Login to the application, perform GET request and get the XSRF Token from GET request RESPONSE HEADERS and pass it in the POST request in Header Manager in Jmeter. That way, I am able to create a new resource using POST. I am not sure why this approach isn't working in Karate.
You must be missing some header. The fastest way you can solve this is by collaborating with someone on the server-side dev team.
Refer to this example in the Karate demos that uses CSRF:

API Post Data to Middleware

Anyone know how I can test posting data to this url? I was given the link by the IT supervisor and trying to have the data posted to the following link by submitting the following form. He said it would accept anything I send it
Could could do this via curl:
curl -X POST -d "data=anything_i_send_it" http://powersource.braindongle.com/lead-manager/lead/new/omgpost/sessions/
Or using another HTTP tool like Hurl.it
Or using a Chrome extension like Postman or REST Console.
Advanced Rest Client is an easy way to do it. It's a free chrome extension that can form http requests with data.