POST with JSON content gives groovy.lang.MissingMethodException

63 views
Skip to first unread message

PeterRigole

unread,
Sep 1, 2011, 9:32:12 AM9/1/11
to REST assured
Hi,

I consistently have problems sending JSON data along with post or put
messages. Even the textbook example fails:

given().content("{ \"message\" : \"hello world
\"}").then().expect().statusCode(200).when().post("/json");

The exception is:

groovy.lang.MissingMethodException: No signature of method:
java.lang.String.call() is applicable for argument types:
(java.lang.String) values: [{ "message" : "hello world"}]
Possible solutions: wait(), any(), wait(long),
split(java.lang.String), any(groovy.lang.Closure),
each(groovy.lang.Closure)
at
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:
54)
at
org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:
46)
at
org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:
40)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:
116)
at
org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:
124)
at
com.jayway.restassured.internal.RequestSpecificationImpl.content(RequestSpecificationImpl.groovy:
389)

Any ideas? I'm using RESTassured 1.2.3.

Best regards,
Peter

Johan Haleby

unread,
Sep 1, 2011, 9:46:58 AM9/1/11
to rest-a...@googlegroups.com
This was actually a (very trivial) bug and it has now been fixed. 

Try using:

given().body("{ \"message\" : \"hello world\"}").then().expect().statusCode(200).when().post("/json");

instead. This should work for you.

Thanks for reporting,
/Johan
Reply all
Reply to author
Forward
0 new messages