Issue: A JSONObject text must begin with '{' at 1 [character 2 line 1]. Solution: // Parse the response into a JSONArray JSONArray jsonArray = new JSONArray(res.asString()); // Iterate through the array of objects for (int i = 0; i < jsonArray.length(); i++) { JSONObject bookObject = jsonArray.getJSONObject(i); String bookTitle = bookObject.getString("title"); System.out.println(bookTitle); // Add assertions if needed // For example: assertEquals(bookTitle, "Expected Title"); }
@user-wl9st1ex1j
7 ай бұрын
yes I did the same
@ishuishu3149
6 ай бұрын
If Assert fails at the first time , will it continue to execute the next iteration ?
@MJ-kd2em
4 ай бұрын
Instead of res.toString() Just use res.asString(). problem will be solved
@palkherohit1
13 күн бұрын
@@MJ-kd2em Thanks bro I've spent more than 1hr to resolve this issue, at last opened the comment section 😂
@gurudattv9567
Жыл бұрын
I dont know how to thank you. You are the best teacher and you make things simple.
@sdetpavan
Жыл бұрын
Welcome
@user-kc6wj7wr6i
4 ай бұрын
Perfectly explained sir.👍
@sdetpavan
4 ай бұрын
Thanks
@satishjaiswal8969
Жыл бұрын
Your All testing videos are awesome 😎
@sdetpavan
Жыл бұрын
Thanks
@VarunG-kq8mf
Ай бұрын
in 50:10 and in 53:40 store.json file got changed as Price values are different Nice transition sir
@rishikeshshah7294
8 ай бұрын
Thank your for your great tutorial. I follow mostly your tutorial while learning Test Automation topics. I had problem in validating the title of last book. I solved it this way. I am posting this solution, because it may help some one who is facing same issue. I was getting Nullpointer exception with this line of code String bookname = res.jsonPath().get("book[3].title").toString(); Solution String bookname = res.jsonPath().get("[3].title").toString(); Assert.assertEquals(bookname,"The Lord of the Rings");
@MandeepSinghSaini5
2 ай бұрын
I was facing this issue and was totally confused. Thanks you so much for sharing this solution!
@shankarlingam4702
Жыл бұрын
Awesome rendition!
@sdetpavan
Жыл бұрын
Thanks
@xXMrThomasXx
2 ай бұрын
Great tutorial, thx for session 4 :)
@sdetpavan
2 ай бұрын
My pleasure!
@Ram_5
5 ай бұрын
Hi Sir..Thanks for sharing this knowledge..Sir, If we want to practice we don't have documents. please attach documents sir..then only we can easily practice what you teach.
@shubhamkamatkar541
Ай бұрын
great explaination thank you sir..
@sdetpavan
Ай бұрын
Welcome
@user-sr2zn4fr7y
Жыл бұрын
Simply Awesome.
@sdetpavan
Жыл бұрын
Many thanks!
@sherryblossomone1098
Жыл бұрын
Thank you so so much... Thank you!
@sdetpavan
Жыл бұрын
Welcome
@user-ei7db1lk9d
6 ай бұрын
Thank you, Sir you are an amazing teacher. I have learned a lot from you. One of your scenarios could be simplified, you don't need to use the loop. .then() .body("book.title", hasItems("The Load of the Rings"));
@Deepti-mr3fd
2 ай бұрын
you are just amazing, sir.......awesome
@sdetpavan
Ай бұрын
Thanks
@olaojeyinka9361
Жыл бұрын
Hi sir, I have a question for you, which automation tool can I use for developing an automation framework for Microsoft Dynamics SL. It does not have a URL. It is remote access.
@AmerikadakiAileniz
Жыл бұрын
Thank you for lessons Mr. Pavan,but when documents are not shared it is very hard for us to practice.I have spent 10 minutes reading comments so see, if anybody shared the doc or not:(
@faribarezaei9469
Жыл бұрын
Your videos are great. Do you have any tutorial for cucumber with Serenity?
@nagasaimaddula56
Ай бұрын
Super explanation sir
@sdetpavan
Ай бұрын
Thanks
@meralaycenk1046
11 ай бұрын
Great 👍 👍
@sdetpavan
11 ай бұрын
Thank you
@mv8167
Жыл бұрын
Great job explaining, thank you. Can we get the code?
@snehadhande5283
Жыл бұрын
Sir, the error @47.34 timestamp is because of sending the response as toString() (which converts an object into string). But the response body we got is not an object, hence we need to use asString() method which converts response into string.
@radwankhan1259
Жыл бұрын
Thanks, solved the problem by replacing toString() --> asString().
@lovishsethi8054
Жыл бұрын
Not able to pass res.asString() in JSONObject , as it's asking value in the form of map .
@v2factsandupdates327
Жыл бұрын
Awesome
@sdetpavan
Жыл бұрын
Thanks
@matinshaikh6102
9 ай бұрын
The json files you are using as example, where its shared?
@gaganvaidya8354
6 ай бұрын
Hi @sdetpavan Sir, first up all thanks for your efforts, whenever I was stuck in my QA journey I followed your videos and it solved my problem recently I started working on API testing and I wondered if we don't have an array in our JSON and we have to find username in the body like you find the all titles in array how we will get those username with Response?
@user-nu6gr7cg1b
5 ай бұрын
Hi sir , getting null values when try to validate the value from json response
@madhavkharge9545
Жыл бұрын
After hitting json-server URL on browser i didn't get any data in it why? only i get { }
@adelajdagega8634
Ай бұрын
Hi sir, great job! Thank you for your efforts. Just one thing: the price of the books at the end of the video is incorrect sir
@user-bj3mh3nm1n
3 ай бұрын
Sir when I passed json response as string to create JSONObject, the compiler is showing error that constructor does not exist
@bbkrishnareddy8886
Жыл бұрын
Sir can you please share the document If I need to rum my lab is there any prerequisite is please help me I am strucking sir
@gkarthick9569
Жыл бұрын
Hi sir, When we can expect python with api testing
@ummadisindhuja
Жыл бұрын
hi sir..good evening...sir i want take testing course from you through online...can you tell me course details and fee..how can I contact you sir ?please give reply sir
@Abdulrahman-my3tu
Жыл бұрын
Will you upload all course videos on udemy ?
@Emleduleymawa
4 ай бұрын
How can i get the json data
@kamleshkr7
Жыл бұрын
50:31 Sir we have to use asString() instead of toString().😊
@hacuong9287
Жыл бұрын
can you explain why, I try to research but still not understand why toString() method is not work in this case?
@suk1607
Жыл бұрын
how can i get store.json file????can any one help me??
@dhananjaypoul3105
7 ай бұрын
Pawan sir please reply... After completing this playlist can i add rest assured in my skillset into my resume....?
@ravibhushan751
5 ай бұрын
Sure you can ...its more than enough
@dhananjaypoul3105
5 ай бұрын
@@ravibhushan751 thank you...
@rangaswamy3839
Жыл бұрын
Sir can you able to do one video related to post request using authentication token pls sir
@ProteinStone
10 ай бұрын
Sir, I have observed two things here when we get "A JSONObject text must begin with '{' at 1 [character 2 line 1]" error. 1. This error won't get resolved by changing this line contentType(ContentType.JSON). contentType has two methods/constructors here where first accepts "ContentType" argument and other accepts String argument. 2. For me, this error got resolved when I wrote "JSONObject json = new JSONObject(res.asString());"
@ramarajuvarma3986
9 ай бұрын
Hi, Even after modifying toString to asString, i am getting error "A JSONObject text must begin with '{' at 1 [character 2 line 1]" . Can you please help me with this error?
@user-my4dx3uc9j
9 ай бұрын
@@ramarajuvarma3986 That is because you have to place the entire book object inside another obj say b eg "b": here place the book object
@himanshuchouhan7899
8 ай бұрын
I am getting same error brother .any findings on resolving this? .please let me know.
@payeldas3874
7 ай бұрын
Thanks a lot... I racked my brain like anything to get it work...thank you thank you thank you
@HanjiMeinSwapnil
8 ай бұрын
as mentioned in the video that you will provide json files you have used , but there is no link provided in description or in comments . Plz provide the link to download
@sachitabala
7 ай бұрын
{ "book": [ { "author": "Niguel Rees", "category": "reference", "price": 150.5, "title": "Sayings of the Century" }, { "author": "Evelyn Waugh", "category": "fiction", "price": 100, "title": "Sword of Honour" }, { "author": "Hermen Melville", "category": "fiction", "isbn": "0-553-21311-3", "price": 75.5, "title": "Moby Dick" }, { "author": "J.R.R. Tolkien", "category": "fiction", "isbn": "0-553-21311-8", "price": 200, "title": "The Lord of the Rings" } ] }
@beatbajao2158
Жыл бұрын
Sir apki api testing playlist mai 2 unwanted videos hai please check
@chandanam1518
Жыл бұрын
Hi Sir,Can we have c# API automation please
@shrikantmahangade8521
6 ай бұрын
Where will i get you pom.xml file
@satyasarma9073
10 ай бұрын
Sir, from Where can i get the json files tht u used in ur local ?
@user-fb3yh7xj2n
Ай бұрын
we have to create our own json data in notepad and save the name with .json
@abhishekdash6853
11 ай бұрын
Where is the stores file
@user-hk9vd6dn6n
6 ай бұрын
Issue: A JSONObject text must begin with '{' at 1 [character 2 line 1]. Solution : JSONObject jo = new JSONObject(res.asString()); for(int i=0; i
@ksdnsdkumar1375
Жыл бұрын
I feel existing chapters on the video slightly indirect. @02:02 Running local API @02:41 checking api by URL @03:27 Create package, class and test method @5:54 Import static packages VALIDATING JSON RESPONSE USING MATCHERS @06:50 Declaring input type in Given() (correction @50:42) @07:21 Declaring URL in GET request in When() @8:00 Validate status code and Header in Then() @09:02 Gather JSON response in POSTMAN for same URL @12:00 JSON pathfinder to find path of specific field @12:51 Using the path, validate a specific field of JSON response in Then() @14:17 Execution of the code VALIDATING JSON RESPONSE USING ASSERTIONS (Without using `Then()`) @16:59 Declaring input type in Given() @17:54 Declaring URL in GET request in When() @18:14 Storing response into variable @19:32 Validating status code using assertions. @21:31 Gather Header in POSTMAN for same URL and Validating Header using assertions. @23:01 Validating specific field of JSON response in Then() using assertions @26:43 Execution of the code @33:10 Converting JSON response into JSONObject @34:33 Gather all values from specific JSON field for same URL in POSTMAN @36:05 Using for loop to print all values from specific JSON field @52:54 Execution of the code @53:26 Drawbacks of this method. @54:53 Using for loop and assertions to validate value from specific JSON field @58:58 Execution of the code @01:01:38 Printing the total of specific values from JSON field. @01:05:10 Execution of the code @01:05:31 Using assertions to validate total of specific values from JSON field. @01:06:04 Execution of the code
@DileepKk-np5xx
Жыл бұрын
Hi Sir, I tried to Run the script, but i m getting the below error. Cannot invoke "Object.toString()" because the return value of "io.restassured.path.json.JsonPath.get(String)" is null.But it is successfull for you, i have done the same thing u did. Please let me know how can i resolve this. Thanks!
@user-fb3yh7xj2n
Ай бұрын
same issue😒😒
@user-fb3yh7xj2n
Ай бұрын
@karimlaaribi9389 following is my data. where i have to add the statement .can you explain me?
@anjalimishra2979
9 ай бұрын
please share these json files for apis
@geethadhandapani257
Жыл бұрын
Sir how to fix this error: A JSONObject text must begin with '{' at 1 [character 2 line 1]. need help. Thank you.
@kanikaxyz5341
Жыл бұрын
Hi, change tostring() to asString() when converting 'res' of Response type into string format. JSONObject jo = new JSONObject(res.asString());
@geethadhandapani257
Жыл бұрын
@@kanikaxyz5341 Thank you
@adityaparde2561
10 ай бұрын
still getting the same error
@Rana-Farhan
7 ай бұрын
Thanks, it really helps@@kanikaxyz5341
@hanumanthap1469
Ай бұрын
could you please share Json files and Code
@jyotiranjanjena5166
9 ай бұрын
how can we get the count of response
@user-fb3yh7xj2n
Ай бұрын
we have to create our own json data in notepad and save the name with .json . take this data and paste it in your notepad
@sideger1710
Жыл бұрын
“application/json’’
@rushitahirpara11
Жыл бұрын
where can we get JSON FILE ?
@kumarshivam7777
Жыл бұрын
@rushitahirpara4811 u got JSON File???
@rushitahirpara11
Жыл бұрын
@@kumarshivam7777 No I haven’t got yet ! Please provide if anyone of you got it then ?
@NITISHKUMAR-bq4df
Жыл бұрын
java.lang.AssertionError: 1 expectation failed. JSON path book[3].title doesn't match. Expected: lord of the rings Actual: null this error is coming at14.20 sir video time
Sir how to fix this error: A JSONObject text must begin with '{' at 1 [character 2 line 1]. need help. Thank you. JSONObject js= new JSONObject(res.asString()); for(int i=0; i
@tijaca1
Жыл бұрын
thanks,it really helped
@manja55544
Ай бұрын
It will be good to use jsonPath while automating applications using rest assured Response res = // get response using REST-assured List titles = res.jsonPath().getList("book.name"); for (String title : titles) { System.out.println(title); }
@bhargavapoola1651
Жыл бұрын
Sir I used below code to fetch titles of books public class JsonResponseParsing { @Test void jsonParsing() { Response res=given() .contentType("ContentType.JSON") .when() .get("localhost:3000/karma"); /* JSONArray json_arr = new JSONArray(res.toString()); //JSONObject single_response = json_arr.get(0); //for single element for(int i=0;i
@snehadhande5283
Жыл бұрын
change JSONArray json_arr = new JSONArray(res.toString()); to JSONArray json_arr = new JSONArray(res.asString()); toString() method is used to convert an object into string. Here we need to convert response into String , so need to use asString() method
@lalkrushnamahore8384
Жыл бұрын
@@snehadhande5283 I also was stuck with same problem. Thanks for solution sneha.
@it.garage
Жыл бұрын
i used res.getBody().asString() insead of res.toString() for JSONArray parameter and it fixed issue
@barsharanimaharana631
8 ай бұрын
JSONArray ja = new JSONArray(res.asString()); for(int i=0;i
@user-dd5vh2ty3v
Жыл бұрын
added asString in plaace of tostring still getting same error @Test() void reponsedata_val3() { Response resp= given() .contentType(ContentType.JSON) .when() .get("localhost:3000/students"); JSONObject json_obj = new JSONObject(resp.asString()); for (int i=0; i < json_obj.getJSONArray("students").length();i++) { String names = json_obj.getJSONArray("students").getJSONObject(i).get("id").toString(); System.out.println(names); }
Пікірлер: 105