Please consider below code,
import org.junit.Test;
import org.omg.CORBA.Request;
import com.jayway.restassured.RestAssured;
import com.jayway.restassured.response.Response;
import static com.jayway.restassured.RestAssured.*;
import static org.hamcrest.Matchers.*;
public class App
{
@Test
public void loginAuthentication()
{
RestAssured.authentication = basic("username", "password");
Response resp = given().
contentType("application/x-www-form-urlencoded").
when().
post("https://unitrends.atlassian.net/login?username=Gayatri.londhe&password=GayatriA4");
System.out.println(resp.prettyPrint());
}
}
I am getting below response,
<div class="aui-message error">
<span class="aui-icon icon-error"/>
<span class="error" id="error-authentication_failure_invalid_credentials">
Sorry, we didn't recognize that username and password combination. Please double-check and try again.
</span>
</div>
How to use authentication in rest-assured, i am able to do rest post request using REST-console (chrome plugin). What am i doing wrong?
I hope to get some help at this. I am new at rest-assured testing.