{"action":"created","issue":{"url":"https://api.github.com/repos/rest-assured/rest-assured/issues/706","repository_url":"https://api.github.com/repos/rest-assured/rest-assured","labels_url":"https://api.github.com/repos/rest-assured/rest-assured/issues/706/labels{/name}","comments_url":"https://api.github.com/repos/rest-assured/rest-assured/issues/706/comments","events_url":"https://api.github.com/repos/rest-assured/rest-assured/issues/706/events","html_url":"https://github.com/rest-assured/rest-assured/issues/706","id":160576239,"number":706,"title":"Unable to store the sessionid from a post to next get request","user":{"login":"DivyaGN","id":15869876,"avatar_url":"https://avatars.githubusercontent.com/u/15869876?v=3","gravatar_id":"","url":"https://api.github.com/users/DivyaGN","html_url":"https://github.com/DivyaGN","followers_url":"https://api.github.com/users/DivyaGN/followers","following_url":"https://api.github.com/users/DivyaGN/following{/other_user}","gists_url":"https://api.github.com/users/DivyaGN/gists{/gist_id}","starred_url":"https://api.github.com/users/DivyaGN/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DivyaGN/subscriptions","organizations_url":"https://api.github.com/users/DivyaGN/orgs","repos_url":"https://api.github.com/users/DivyaGN/repos","events_url":"https://api.github.com/users/DivyaGN/events{/privacy}","received_events_url":"https://api.github.com/users/DivyaGN/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-16T04:40:32Z","updated_at":"2016-06-16T05:55:42Z","closed_at":null,"body":"Hi I am trying to write this code for the first time to use the same session for multiple rest calls.\r\n\r\nmy application has a autentication url and the same sessiln i have to use to do get requests further.\r\n\r\nPlease help me out......\r\n\r\npackage API;\r\n\r\nimport org.junit.Test;\r\n\r\nimport io.restassured.RestAssured;\r\nimport io.restassured.filter.session.SessionFilter;\r\n\r\nimport static org.junit.Assert.*;\r\n\r\n\r\npublic class Sample {\r\n    @Test\r\n    public void testLogin() {\r\n    \tString myJson = \"{\\\"AuthenticateUserRequest\\\":{\\\"user\\\":{\\\"userName\\\":\\\"divya\\\",\\\"password\\\":\\\"***********!\\\"}}}\";\r\n        SessionFilter session1 = new SessionFilter();\r\n        String sessionId = session1.getSessionId();\r\n\r\n        RestAssured.given().\r\n                filter(session1).\r\n                contentType(\"application/json\").body(myJson).\r\n                when().\r\n                post(\"http://as-rtp-infra-virl-dev-web01.cisco.com:8080/netsim/authenticate\").\r\n                then().\r\n                statusCode(200);\r\n\r\n        RestAssured.given().\r\n                filter(session1).\r\n                when().\r\n                get(\"http://as-rtp-infra-virl-dev-web01.cisco.com:8080/netsim/projects\").\r\n                then().\r\n                statusCode(200);\r\n\r\n    }\r\n}\r\n also tried\r\n\r\n\r\npackage API;\r\n\r\n\r\nimport org.junit.Assert;\r\nimport org.junit.Test;\r\nimport io.restassured.RestAssured;\r\nimport io.restassured.response.Response;\r\nimport io.restassured.specification.RequestSpecification;\r\nimport io.restassured.filter.Filter;\r\nimport java.io.FileInputStream;\r\nimport java.util.Properties;\r\n\r\nimport org.hamcrest.Matchers;\r\n\r\n\r\npublic class ProjectInfo {\r\n \r\n\t@Test\r\n\tpublic void RestSession_basicauth() {\r\n\t\t\t\t\r\n\t\tString myJson = \"{\\\"AuthenticateUserRequest\\\":{\\\"user\\\":{\\\"userName\\\":\\\"Divya\\\",\\\"password\\\":\\\"*********!\\\"}}}\";\r\n\t\tSystem.out.println(System.getProperty(\"user.dir\"));\r\n\t\tProperties prop = new Properties();\r\n\t\tFileInputStream file;\r\n\t\ttry {\r\n\t\t\tfile = new FileInputStream(System.getProperty(\"user.dir\")+\"//ConfigFile//TestData.properties\");\r\n\t\t\tprop.load(file);\r\n\t\t} catch (Exception e) {\r\n\t\t\t// TODO Auto-generated catch block\r\n\t\t\te.printStackTrace();\r\n\t\t}\r\n\t\t\r\n\t\tString URL1 = prop.getProperty(\"AuthenticateURI\");\t\r\n\t\tString URL2 = prop.getProperty(\"ProjectDetailsURI\");\t\r\n\t\t\r\n\t\t\r\n\t\tResponse response=RestAssured.given().contentType(\"application/json\").body(myJson).expect().statusCode(200).log().ifError().when().post(URL1);\r\n\t\t\r\n\t\tString sessionId = response.sessionId();\r\n\t\t\r\n\t\tresponse = RestAssured.given().\r\n                contentType(\"application/json\").cookie(\"JSESSIONID=\" + sessionId).when().get(URL2);\r\n\r\n\t\tString Body =response.getBody().asString();\r\n\t\tSystem.out.println(Body);\r\n\t\t\r\n\t\tAssert.assertThat(response.getStatusCode(), Matchers.equalTo(200));\r\n\t\t\r\n\t\t\r\n\t\t  \r\n\t\t\r\n\t\t\r\n}\r\n\t\r\n\t\r\n}\r\n\r\n\t"},"comment":{"url":"https://api.github.com/repos/rest-assured/rest-assured/issues/comments/226394684","html_url":"https://github.com/rest-assured/rest-assured/issues/706#issuecomment-226394684","issue_url":"https://api.github.com/repos/rest-assured/rest-assured/issues/706","id":226394684,"user":{"login":"johanhaleby","id":187029,"avatar_url":"https://avatars.githubusercontent.com/u/187029?v=3","gravatar_id":"","url":"https://api.github.com/users/johanhaleby","html_url":"https://github.com/johanhaleby","followers_url":"https://api.github.com/users/johanhaleby/followers","following_url":"https://api.github.com/users/johanhaleby/following{/other_user}","gists_url":"https://api.github.com/users/johanhaleby/gists{/gist_id}","starred_url":"https://api.github.com/users/johanhaleby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johanhaleby/subscriptions","organizations_url":"https://api.github.com/users/johanhaleby/orgs","repos_url":"https://api.github.com/users/johanhaleby/repos","events_url":"https://api.github.com/users/johanhaleby/events{/privacy}","received_events_url":"https://api.github.com/users/johanhaleby/received_events","type":"User","site_admin":false},"created_at":"2016-06-16T05:55:42Z","updated_at":"2016-06-16T05:55:42Z","body":"Is the name of the cookie JSESSIONID? If not may can configure the SessioFilter to use another name. Maybe you can also use the new CookieFilter (version 3.0.0) and see if that works?"}}
{"actor":{"display_login":"johanhaleby"}}