How to send multiple JSON's as payload for a HttpRequest from a csv or text file.

1,538 views
Skip to first unread message

xara...@gmail.com

unread,
Nov 8, 2018, 5:54:28 AM11/8/18
to jmeter-plugins
Hi All,

Can someone help me on how to send  multiple JSON's as payload for a HttpRequest from a csv or text file. I'm doing some API Perf testing, where I want to send multiple json's(diff json for diff use cases) as message body for the API request.

I tried by putting the json's in an in-formatted way with one json in one line and next in next line like which I have multiple jsons/lines in a text file, and I'm reading this file using CSV Data Config and trying to put the  variable name as Request payload.

When the script starts running getting the below exception,

{"httpStatus":503,"serviceId":0,"errorCode":"ITEM50000","debugMessage":"JSON parse error: Unexpected end-of-input: expected close marker for Object (start marker at [Source: (PushbackInputStream); line: 1, column: 1]); nested exception is com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Object (start marker at [Source: (PushbackInputStream); line: 1, column: 1])\n at [Source: (PushbackInputStream); line: 1, column: 51]","messageArgs":{}}


Can some one please help on this.

gli...@gmail.com

unread,
Nov 8, 2018, 12:08:43 PM11/8/18
to jmeter-plugins
The easiest solution is:

  1. Put each JSON into a separate file
  2. Use Directory Listing Config plugin to read the files into a JMeter Variable 
  3. Use __FileToString() function in the HTTP Request sampler body data to read the file from the directory. 

Anand Raj

unread,
Nov 9, 2018, 1:26:22 AM11/9/18
to jmeter-...@googlegroups.com, gli...@gmail.com
Hi Thanks... even I thought the same. I'm going to do the same by send each JSON as a file using  __FileToString() function  rather than a variable. 

Can you please tell is there a way to get response for each diff json request...rather than a single report for overall requests.

--
You received this message because you are subscribed to a topic in the Google Groups "jmeter-plugins" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jmeter-plugins/MKr7SyEKYnQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jmeter-plugin...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages