Re: Nested json object with NVPair for POST
Marc Holden <[email protected]>
| Newsgroups | gmane.comp.java.grinder.user |
|---|---|
| Message-ID | <CADV_OVXBdKyV6PJSKzoZDybmmrGSivgtpAXrQ96GfmdMYTqzQA@mail.gmail.com> |
Looks like you are missing quotes userEmail, passwordToUse (all instances) and app_id. On Mon, Nov 18, 2013 at 4:41 PM, Jai P <[email protected]> wrote: > I want to represent the following json string with NVPair in Grinder: > > json = '''{ > \"user\" : userEmail,\r\n > \"password\" : passwordToUse,\r\n > \"app_id\" : appID,\r\n > \"rule_id\" : \"login\",\r\n > \"uidpwd\" : {\"id\" : userEmail, \"password\" : > passwordToUse},\r\n > \"sdk_id\" : \"1\" \r\n > }''' > > > Note the nested object - uidpwd. How can I create this with NVPair? I > would like to use *POST > <http://grinder.sourceforge.net/g3/script-javadoc/net/grinder/plugin/http/HTTPRequest.html#POST(java.lang.String,%20HTTPClient.NVPair[])>* > (java.lang.String uri, NVPair<http://grinder.sourceforge.net/g3/script-javadoc/HTTPClient/NVPair.html> > [] formData) > > If I use the above string as is with the request.POST(url, json), I get a > 400 with this error: > > HTTP Status 400 - org.codehaus.jackson.JsonParseException: Unexpected > character ('u' (code 117)): expected a valid value (number, String, array, > object, 'true', 'false' or 'null') > at [Source: org.apache.catalina.connector.CoyoteInputStream@c8d8c50; > line: 1, column: 22]</h1><HR size="1" noshade="noshade"><p><b>type</b> > Status report</p><p><b>message</b> > <u>org.codehaus.jackson.JsonParseException: Unexpected character ('u' (code > 117)): expected a valid value (number, String, array, object, 'true', > 'false' or 'null') > at [Source: org.apache.catalina.connector.CoyoteInputStream@c8d8c50; > line: 1, column: 22]</u></p><p><b>description</b> <u>The request sent by > the client was syntactically incorrect.</u></p> > > > The same string works with curl and I get a 200. > > curl -H "Content-Type: application/json" -X POST > http://blah.com:8080/verification/uidpwd -d {\"user\":\" > [email protected] > \",\"app_id\":\"1\",\"rule_id\":\"login\",\"uidpwd\":{\"id\":\" > [email protected]\",\"password\":\"Password$\"},\"sdk_id\":\"1\"} > > What am I missing? > > Jai > > > ------------------------------------------------------------------------------ > Shape the Mobile Experience: Free Subscription > Software experts and developers: Be at the forefront of tech innovation. > Intel(R) Software Adrenaline delivers strategic insight and game-changing > conversations that shape the rapidly evolving mobile landscape. Sign up > now. > http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk > _______________________________________________ > grinder-use mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/grinder-use > > ------------------------------------------------------------------------------ Shape the Mobile Experience: Free Subscription Software experts and developers: Be at the forefront of tech innovation. Intel(R) Software Adrenaline delivers strategic insight and game-changing conversations that shape the rapidly evolving mobile landscape. Sign up now. http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk _______________________________________________ grinder-use mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/grinder-use