Ich teste eine REST API mit Rest Assured. Ich habe einen Fehler beim Versuch, sowohl mit einem Parameter im URL- als auch im Body-Inhalt POST zu senden. Dies funktioniert beim manuellen Testen korrekt. Das Entfernen der Parameter die URL bilden, ist keine OptionRest Assured - kann nicht mit Parametern und Körper POST
Testcode:
String endpoint = http://localhost:8080/x/y/z/id?custom=test;
String body = "[{\"boolField\":true,\"intField\":991},
{\"boolField\":false,\"intField\":998}]";
expect().spec(OK).given().body(body).post(endpoint);
, das die folgenden Fehler auslöst, wenn
laufenYou can either send parameters OR body content in the POST, not both!
java.lang.IllegalStateException: You can either send parameters OR body content in the POST, not both!
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:198)
at com.jayway.restassured.internal.RequestSpecificationImpl.sendRequest(RequestSpecificationImpl.groovy:282)
at com.jayway.restassured.internal.RequestSpecificationImpl.this$2$sendRequest(RequestSpecificationImpl.groovy)
at com.jayway.restassured.internal.RequestSpecificationImpl$this$2$sendRequest.callCurrent(Unknown Source)
at com.jayway.restassured.internal.RequestSpecificationImpl.post(RequestSpecificationImpl.groovy:83)
...
Warum Rest nicht funktioniert Assured zulassen, dass beide Parameter und Körpergehalt Ein Eintrag?
Im mit dem Rest zugesichert 1.1.6, die ziemlich alt ist. Betrachtet man jedoch den Code auf [github] (https://github.com/jayway/rest-sured/blob/master/rest-assured/src/main/groovy/com/jayway/restassured/internal/RequestSpecificationImpl.groovy) Dies scheint immer noch ein Problem zu sein –
Ich wusste nicht, dass Sie Post-Parameter und einen Körper haben könnten, also vielleicht auch die Schöpfer von Rest Assured nicht. Hast du selbst versucht, Rest Assured zu bauen und diesen Check zu kommentieren? – mercutio
erstellt ein Problem für die Ruhe: http://code.google.com/p/rest-assured/issues/detail?id=196&thanks=196&ts=1346105863 –