Johan Haleby edited this page Aug 17, 2018 · 37 revisions


  1. Q: I'm running into exceptions like the one below after having upgraded to REST Assured 1.8+
   java.lang.IncompatibleClassChangeError: Found interface org.objectweb.asm.MethodVisitor, but class was expected
     at org.codehaus.groovy.runtime.callsite.CallSiteGenerator.genConstructor(
     at org.codehaus.groovy.runtime.callsite.CallSiteGenerator.genPojoMetaMethodSite(
     at org.codehaus.groovy.runtime.callsite.CallSiteGenerator.compilePojoMethod(
     at org.codehaus.groovy.reflection.CachedMethod.createPojoMetaMethodSite(
     at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.createCachedMethodSite(
     at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.createPojoMetaMethodSite(
     at groovy.lang.MetaClassImpl.createPojoCallSite(
     at org.codehaus.groovy.runtime.callsite.CallSiteArray.createPojoSite(
> This is because you have conflicting versions of [asm]( in your classpath. Groovy depends on version 4 and something else in your classpath require asm 3. The solution is to exclude `groovy` form REST Assured and depend on `groovy-all` instead. If you're using Maven you can do like this:
        <!-- Exclude Groovy because of classpath issue -->
    <!-- Needs to be the same version that REST Assured depends on -->
If you're using Gradle do like this:
testCompile (group: '', name: 'rest-assured', version:'3.1.1') {
        exclude(module: 'groovy')
testCompile group: 'org.codehaus.groovy', name: 'groovy-all', version:'2.4.6'
  1. Q: How can I determine if a JSON response path exists or doesn't exist?

Imagine that we have a resource called "/json" that returns the following JSON response:

   "done": true,
   "records": [
           "Name": "Bob",
           "Phone": null,
           "CreatedDate": "2013-07-02T14:25:06Z",
           "Id": "0ca00000piscd1bj"
   "size": 1

To verify that the records list contains the attribute Phone (even though it's null) we can do like this:

get("/json").then().assertThat().body("records.any { it.containsKey('Phone') }", is(true));

Likewise we can check that records doesn't contain an attribute called x:

get("/json").then().assertThat().body("records.any { it.containsKey('x') }", is(false));

To verify that a JSON object contains an element, for example to check that "size" is defined in the example above you can do like this:

get("/json").then().assertThat().body("any { it.key == 'size' }", is(true));
  1. Issues REST Assured with Grape

If you run into issues with Grapes such as:

General error during conversion: Conflicting module versions. Module [groovy-xml is loaded in version 2.4.6 and you are trying to load version 2.4.4". This happens when running rest-assured 3.1.1 in a groovy script with any recent version of groovy except 2.4.4.

you should try excluding org.codehaus.groovy:groovy-xml and org.codehaus.groovy:groovy-json:

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.