I have a Talend job which has an input CSV file which needs to be converted to a JSON format and then using a tRESTclient/tREST , make a HTTP call request and post data.
In the current job, I have an Elasticsearch server installed on my local machine and provided that URL.
I was able to convert the files to JSON format and also verified with a tlogrow component but unable to post data.
(P.S: I was able to post data using a bulk Java code, loading jar files and making HTTP call and sending parameters using a tJAVArow component. So no issue with my localhost and posting data.)
After converting the data from input file to JSON format, set the context variable with your JSON data and then make the rest call. You can add the context variable in the HHTP Body. example : context.json_post without double quotes.
Related
I have a post request naming 'Register' which will allow users to upload .csv files or .json files I want to test the load on this API with different CSV /JSON files for different users. I have added files path in 'PLAN.CSV' .Each file contain JSON DATA-
Please guide
Request image and result image is attached hereResquest
Response
CSV CONFIG SET
Your syntax is incorrect, the valid one for the __FileToString() function would be:
${__FileToString(${JSON_FILE},,)}
Consider using Functions Helper Dialog if you're uncertain
Your setup doesn't really "upload" the file, it sends the file as the HTTP POST body, the "upload" assumes either PUT or POST with multipart-form/data. Again if you're not sure that you're building the request correctly just record it using JMeter's HTTP(S) Test Script Recorder, just make sure that the file(s) you're uploading are present in "bin" folder of your JMeter installation
So, I have an XML file that needs to be sent to a server via the POST request. Everything works, however, here is an issue. This XML file has a transaction ID that needs to be incremented every time when it's being sent to a server. When I create multiple threads(requests) and send them over to the server, only one request gets processed, and everything else gets declined because they all have the same transaction ID. I was wondering if there is a way to increment a transaction ID inside the XML file with every generated thread?
Just use __counter function call where you have currently the transaction id:
${__counter(FALSE)}
It depends on how you're sending the file.
If you're doing it via Body Data tab of the HTTP Request sampler using __FileToString() function just replace the transaction ID with __threadNum() function in the file itself and wrap everything into __eval() function like:
${__eval(${__FileToString(/path/to/your/file.xml,,)})}
more information: Here’s What to Do to Combine Multiple JMeter Variables
If you're sending the file via "Files upload" tab the only way is to read the file using JSR223 PreProcessor, change the value and write it back in the runtime, see Processing XML article for more details.
I have used AMQP Publisher to publish the message in RabbitMQ then I use AMQP Consumer as listener. In the View Results Tree the messages from the queue in shown in the request tab of AMQP Consumer. My question is how to extract data from that request. I tried following the Bean Shell Post Processor but it seems it will only work on Http request. I tried to use JSR223 Post Processor and XPath extractor but it doesn't work as well. Any help?
I wanted to extract the documentId from the request. Here is the Request pattern.
I have already tried following links:
Extracting value from jmeter post request
how to extract value from request in Jmeter
How to extract the values from request input xml in jmeter
The statement that you tried something without sharing the code doesn't make sense
Posting JSON data or code as image is not the best idea
Any reason to extract data from the request? Normally people know everything about the request hence don't require to extract anything from it. Even if they do - they should normally able to store the request data into a JMeter Variable and apply the relevant Post-Processor to it.
Whatever, just in case here is the solution:
Add JSR223 PostProcessor (if you really want to do this using the Post-Processor) as a child of the request
Put the following code into "Script" area:
vars.put('foo', com.jayway.jsonpath.JsonPath.read(sampler.getArguments().getArgument(0).value,'$..documentId')[0])
That's it, you should be able to access the extracted value as ${foo} where required.
References:
JsonPath: Getting Started
Apache Groovy - Why and How You Should Use It
I'm using JMeter v3.2 and I put up a really simple test plan for testing something. I have a csv file where I save all URLs acquired by a crawler. The URLs are just normal (http://something.com).
After reading those in from the CSV Config and writing them into my HTTP request sampler I get the following issue. The problem comes with the default protocol of JMeter which turns my request URL into this:
GET http://[http://something.com/]/.
Is there a way to turn that off?
Never put anything but ip address or hostname into Server Name or IP input of the HTTP Request sampler.
If you are getting the whole URL from CSV file - use Path input instead like:
Demo (as per View Results Tree listener)
See Using CSV DATA SET CONFIG guide to learn more about parameterisation of your JMeter test with CSV files.
Can I have Paw for mac (http rest client) read Dynamic Values from a csv or json file? I need to run 10000 APIs by using different Dynamic Values in my collections.
You could create a dynamic value extension, and use readFile() to read your json file.
I have created a dynamic value extension for passwords, and other such stuff that I don't want to share, when I share my Paw documents.
Please note that because of sandboxing, your json file must live inside you extension folder.