Rest-Assured JIRA Java unable to get Response -


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 getting below response,

<div class="aui-message error">      <span class="aui-icon icon-error"/>      <span class="error" id="error-authentication_failure_invalid_credentials">         sorry, didn't recognize username , password combination. please double-check , try again.      </span> </div> 

how use authentication in rest-assured, able rest post request using rest-console (chrome plugin). doing wrong?

i hope @ this. new @ rest-assured testing.

try this...

response resp = given().             contenttype("application/x-www-form-urlencoded").expect().response().statuscode(200).             when().             post("https://unitrends.atlassian.net/login?username=gayatri.londhe&password=gayatria4"); 

it fetch response if response status 200.change it,if service endpoint returns other 200 on success.

try this

@beforeclass public void setup() throws org.json.jsonexception, ioexception {   //assigning base url     restassured.baseuri = "https://unitrends.atlassian.net/";     //assigning default port     restassured.port = <port>     restassured.basepath = "login";     restassured.config = config().redirect(redirectconfig.redirectconfig().followredirects(true).and().allowcircularredirects(true).maxredirects(100)); } @test public void testrestserviceauthentication() {     //for method basic authorization,its expecting response code 200     response res = given().expect().response().statuscode(200).when().post("?username=gayatri.londhe&password=gayatria4");     system.out.println(res.getbody().asstring()); } 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -