--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Could it be because of this: https://www.jayway.com/2012/10/17/what-you-may-not-know-about-http-redirects/
On Fri, Sep 30, 2016 at 5:34 PM, Sumit Bhardwaj <17.sumit...@gmail.com> wrote:
I have a case where I need to send an form-data key and value in API for eg:
API: xyz.com
form-data key: test
form-data value: testValue
I already tried with body,formParam, parameters etc but always get a status code 301.
Please share some examples which showing sending form-data key value using patch request.
Thanks in advance.
--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
given().
formParam("firstName", "John").
formParam("lastName", "Doe").
when().
patch("/greetPatch").
then().
body("greeting", equalTo("Greetings John Doe"));
PATCH /greetPatch HTTP/1.1
Accept: */*
Content-Type: application/x-www-form-urlencoded; charset=ISO-8859-1
Content-Length: 27
Host: localhost:8080
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_60)
Accept-Encoding: gzip,deflate
firstName=John&lastName=Doe
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured+unsubscribe@googlegroups.com.
If the 301 status code is received in response to a request other
than GET or HEAD, the user agent MUST NOT automatically redirect the
request unless it can be confirmed by the user, since this might
change the conditions under which the request was issued.
Note: When automatically redirecting a POST request after
receiving a 301 status code, some existing HTTP/1.0 user agents
will erroneously change it into a GET request.
DefaultHttpClient client = new DefaultHttpClient();
client.setRedirectStrategy(new DefaultRedirectStrategy() {
@Override
protected boolean isRedirectable(String method) {
return true;
}
});To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured+unsubscribe@googlegroups.com.
import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import static com.jayway.restassured.RestAssured.*; import com.jayway.restassured.RestAssured; import com.jayway.restassured.response.Response; public class PatchRequestTest { @BeforeClass public void setBaseUri () { RestAssured.baseURI = "https://localhost:3000"; } @Test public void updateUsingPatch () { Posts post = new Posts(); post.setId ("3"); post.setTitle ("Hello Vietnam"); given().body (post) .when () .contentType (ContentType.JSON) .patch ("/posts/3"); } }