# how we can pass JSON string as a parameter and two normal parameters also(like "userid":"user1",  "pageId":1       ... etc) to test the REST service with complete code

**URL:** <https://community.gatling.io/t/how-we-can-pass-json-string-as-a-parameter-and-two-normal-parameters-also-like-userid-user1-pageid-1-etc-to-test-the-rest-service-with-complete-code/1429>\
**Category:** Gatling (Open-Source)\
**Created:** [September 17, 2014, 11:04am UTC](https://community.gatling.io/t/how-we-can-pass-json-string-as-a-parameter-and-two-normal-parameters-also-like-userid-user1-pageid-1-etc-to-test-the-rest-service-with-complete-code/1429 "2014-09-17T11:04:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raja\_Thumati](https://avatars.discourse-cdn.com/v4/letter/r/f475e1/32.png) [@Raja\_Thumati](https://community.gatling.io/u/Raja_Thumati)\
**Post date:** [September 17, 2014, 11:04am UTC](https://community.gatling.io/t/how-we-can-pass-json-string-as-a-parameter-and-two-normal-parameters-also-like-userid-user1-pageid-1-etc-to-test-the-rest-service-with-complete-code/1429/1 "2014-09-17T11:04:45Z")

</div>

i am new to gatling and my task is to test the REST services?  
any suggetions greatly appreciated.

---

<div class="post-metadata">

**Author:** ![Santhosh](https://avatars.discourse-cdn.com/v4/letter/s/f07891/32.png) [@Santhosh](https://community.gatling.io/u/Santhosh)\
**Post date:** [September 17, 2014, 5:26pm UTC](https://community.gatling.io/t/how-we-can-pass-json-string-as-a-parameter-and-two-normal-parameters-also-like-userid-user1-pageid-1-etc-to-test-the-rest-service-with-complete-code/1429/2 "2014-09-17T17:26:01Z")

</div>

use can pass json string like below.

.body(StringBody(""" “”")).asJSON

---

<div class="post-metadata">

**Author:** ![Raja\_Thumati](https://avatars.discourse-cdn.com/v4/letter/r/f475e1/32.png) [@Raja\_Thumati](https://community.gatling.io/u/Raja_Thumati)\
**Post date:** [September 18, 2014, 7:16am UTC](https://community.gatling.io/t/how-we-can-pass-json-string-as-a-parameter-and-two-normal-parameters-also-like-userid-user1-pageid-1-etc-to-test-the-rest-service-with-complete-code/1429/3 "2014-09-18T07:16:18Z")

</div>

Thank you for your response.

But by POSTing parameters(JSON string and two other) like that,it is not sending any request to REST

i got 415 error…

so please tell me how to POST parameters using POST

my parameters are

param1=user1  
param2=1  
param3=5

param4=[{“level”:“levelname1”,“number”:“two”},{“level”:“levelname2”,“number”:“three”}]

note: param4 is JSON string

by sending those parameters in POST, i want to test my REST…

in my case response also as JSON only…

---

<div class="post-metadata">

**Author:** ![fugmag](https://avatars.discourse-cdn.com/v4/letter/f/d78d45/32.png) [@fugmag](https://community.gatling.io/u/fugmag)\
**Post date:** [October 15, 2014, 12:23pm UTC](https://community.gatling.io/t/how-we-can-pass-json-string-as-a-parameter-and-two-normal-parameters-also-like-userid-user1-pageid-1-etc-to-test-the-rest-service-with-complete-code/1429/4 "2014-10-15T12:23:15Z")

</div>

Given:

.body(StringBody(""" {“offerId”: “123”, “membershipId”: “123”, “osName”: “iOS”, “osVersion”: “8.02”} “”")).asJSON

can I parameterize membershipId like this:

.body(StringBody(""" {“offerId”: “123”, “membershipId”: “${memberID}”, “osName”: “iOS”, “osVersion”: “8.02”} “”")).asJSON

given a .csv file with contents:

memberID  
123  
123  
123  
123

and given

val scn = scenario(“Scenario”)

.feed(csv(“membershipId.csv”).random)

.  
.  
.

Magnus

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [October 15, 2014, 12:26pm UTC](https://community.gatling.io/t/how-we-can-pass-json-string-as-a-parameter-and-two-normal-parameters-also-like-userid-user1-pageid-1-etc-to-test-the-rest-service-with-complete-code/1429/5 "2014-10-15T12:26:25Z")

</div>

Again: yes, that’s exactly what StringBody is intended for…

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [September 3, 2015, 12:30pm UTC](https://community.gatling.io/t/how-we-can-pass-json-string-as-a-parameter-and-two-normal-parameters-also-like-userid-user1-pageid-1-etc-to-test-the-rest-service-with-complete-code/1429/6 "2015-09-03T12:30:48Z")

</div>

You’d have to first store a “dateVar” attribute in the session, and then use the proper Gatling EL syntax in your template (${dateVar} instead of $dateVar).  
Check the documentation.
