1

This is the Hierarchy i have on my Testplan enter image description here

I have Beanshell preprocessor as below:

import org.json.JSONArray;
import org.json.JSONObject;
JSONObject obj = new JSONObject();

obj.put("customerId", "1234");
obj.put("dataSourceName", "ABCD");
JSONArray relateddata = new JSONArray();
relateddata.add("abc", "abc");
obj.put("relatedData", relateddata);

String data = obj.toJSONString();

vars.put("request", data);

My HttP Request is as below:

${request};

My RequestBody is :

POST http://www.url.com (just an example)

POST data:
${request};

[no cookies]

Could someone help me understand why my request variable is not being replaced and how can i get that replaced?

Usr_Dev
  • 77
  • 1
  • 1
  • 9

2 Answers2

0

You should put request as a string

  vars.put("request", data);
Ori Marko
  • 56,308
  • 23
  • 131
  • 233
0

JsonArray cannot be added to Jsonobject directly without converting into to JSONobject.

Usr_Dev
  • 77
  • 1
  • 1
  • 9