-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCreateChangeRequest.java
More file actions
47 lines (30 loc) · 1.04 KB
/
CreateChangeRequest.java
File metadata and controls
47 lines (30 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package day1;
import org.testng.annotations.Test;
import io.restassured.RestAssured;
import io.restassured.authentication.AuthenticationScheme;
import io.restassured.http.ContentType;
import io.restassured.path.xml.XmlPath;
import io.restassured.response.Response;
public class CreateChangeRequest {
@Test
public void createCR() {
// End Point
RestAssured.baseURI = "https://dev64481.service-now.com/api/now/v2/table/change_request";
// Authorization
AuthenticationScheme basic = RestAssured.basic("admin", "7QSEbbY9Hnqb");
RestAssured.authentication = basic;
// Post the request
Response post = RestAssured
.given()
.contentType(ContentType.JSON)
.body("{\"description\" : \"Babu\"}")
.accept(ContentType.XML)
.post();
// response print
post.prettyPrint();
// convert to xml, field, print
XmlPath xmlPath = post.xmlPath();
String description = xmlPath.get("response.result.description");
System.out.println(description);
}
}