REST Assured Beginner Tutorial 6 | GET & POST

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ต.ค. 2024

ความคิดเห็น • 86

  • @SumanKumar-mn5sg
    @SumanKumar-mn5sg 8 หลายเดือนก่อน

    Awesome Raghav.. You are blessed to teach this effectively. I can only say Thank You.. I regularly follow your videos to learn more about

    • @RaghavPal
      @RaghavPal  8 หลายเดือนก่อน

      So nice of you Suman.. humbled

  • @akashmurumkar
    @akashmurumkar 3 ปีที่แล้ว +6

    Your a gem to the Automation Community & Bread n butter for many :)

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว +2

      So happy and humbled to see this Akash

  • @TravelNow-vl1fh
    @TravelNow-vl1fh 6 หลายเดือนก่อน

    Hello bro I learnt this in 30 mins you are an absolute legend,🎉

    • @RaghavPal
      @RaghavPal  6 หลายเดือนก่อน +1

      Glad it helped.. humbled

  • @hassellvinny
    @hassellvinny ปีที่แล้ว

    Thanks Raghav, another great video!

  • @rahuldeshpande7725
    @rahuldeshpande7725 2 ปีที่แล้ว

    Great teaching sir

    • @RaghavPal
      @RaghavPal  2 ปีที่แล้ว

      Thanks and welcome Rahul

  • @rajkamalm420
    @rajkamalm420 3 หลายเดือนก่อน

    Superb videos , thankyou sir

    • @RaghavPal
      @RaghavPal  3 หลายเดือนก่อน

      Most welcome Raj

  • @sreelatha4230
    @sreelatha4230 7 วันที่ผ่านมา

    Thanks a lot Raghav, for very easy and excellent teaching 👍 very helpful to learn in less time even in a day 🫡

    • @RaghavPal
      @RaghavPal  5 วันที่ผ่านมา

      Most welcome Sree Latha

  • @saranyajothi9691
    @saranyajothi9691 2 ปีที่แล้ว +1

    Kindly update videos on hamrest matcher methods and rest assured class methods and so on which we use on rest api pls update in depth

    • @RaghavPal
      @RaghavPal  2 ปีที่แล้ว

      I will check and update Saranya

  • @Nykster
    @Nykster 2 ปีที่แล้ว

    You are brilliant!

    • @RaghavPal
      @RaghavPal  2 ปีที่แล้ว

      Thanks for watching Anyik

  • @prashantj7839
    @prashantj7839 3 ปีที่แล้ว

    Very well explained

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว

      Glad it was helpful Prashant

  • @rashmichavan8317
    @rashmichavan8317 ปีที่แล้ว

    Amazing 👍🏼👍🏼👍🏼

  • @prabaldutta
    @prabaldutta 3 ปีที่แล้ว +1

    Hi Raghav, my requirement is to compare the responses of two end points in JSON using POST request. I have an old end point and a newer version. The result should be the same except few known values like Reference# which will be unique for each POST request. How to approach it? Also, I need test the same using 500 test data to run through both old and new end points and verify the results are same. Please help if there is a smart way of doing the comparison.

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว

      Hi Prabal, I will check and try to do a session, Meanwhile, pls check there should be some examples online

  • @abhijithkumar4896
    @abhijithkumar4896 3 ปีที่แล้ว

    there is some caution in line number 42 and 43 as below where json contents are added into "request" object. Please can you give solution for this.
    "Type safety: The method put(Object, Object) belongs to the raw type HashMap. References to generic type HashMap should be parameterized"

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว +1

      Hi, this may be due to the json library we are using. In case its only warning, can proceed.
      stackoverflow.com/questions/35453110/json-simple-causes-compiler-warning-type-safety-the-method-putobject-object

    • @AyyAppA_009
      @AyyAppA_009 3 ปีที่แล้ว

      @@RaghavPal Hi Sir, according to stackoverflow comments we need to use GSON or JACKSON lib instead of JSONSimple...?

  • @altwathaidar3447
    @altwathaidar3447 3 ปีที่แล้ว

    Thank you man for this video!

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว

      Most welcome Altwat

  • @yuktibaheti621
    @yuktibaheti621 3 ปีที่แล้ว

    Hello Raghav!!
    I have a query related to payment portal in case of api
    How can we do payments thru api
    Scenarios:
    We booked a hotel
    We now have to do payment thru credit card
    But this api request is asking for some encrypted data too
    Which is dynamic in nature
    How can we handle such scenarios
    Please suggest

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว

      Hi Yukti, you just need to have APIs for these requests, Check with your team, if you have you can just follow the tutorials

  • @tester4044
    @tester4044 3 ปีที่แล้ว

    Very Good Lesson!

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว +1

      Glad to hear that!

  • @elmariscal5394
    @elmariscal5394 3 ปีที่แล้ว

    Hi Raghav, you are creating request json object and then parsing it to a json string as well. I was wondering that maybe the second step is not necessary as the request is already in a json request format. It is just to show that it can be parsed into another format , is that correct?

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว +1

      Hi Frank, ya it that case may not be required, can try at your end and if working, should be fine

  • @AnhNguyen-zp4iw
    @AnhNguyen-zp4iw 2 ปีที่แล้ว

    Greate website, I highly recommend it

  • @ievgeniikravtsov1597
    @ievgeniikravtsov1597 3 ปีที่แล้ว

    Thanks a lot!

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว

      You're welcome!

  • @shwetabolar
    @shwetabolar 2 หลายเดือนก่อน

    sir , can you explain me what is the benefit i get if i join your channel?

    • @RaghavPal
      @RaghavPal  2 หลายเดือนก่อน

      Shweta
      Joining is not mandatory.. it's only if you want to support my work for free education to all.. you will get all the benefits, videos, etc even if you don't join

  • @amadhavi5190
    @amadhavi5190 3 ปีที่แล้ว

    Hi raghav, can you make videos for mobile testing using espresso and xctest

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว +1

      I will plan Madhavi

  • @honeythakur1526
    @honeythakur1526 2 ปีที่แล้ว

    Hi Ragav,
    How to initialize multiple RestAssured url in the same project without overriding each other?
    I have multiple modules within same project which needs to communicate with entirely 2 different REST API systems. I want to use Rest Assured for both. could you please let me know the process to define multiple base URI and use it.

    • @RaghavPal
      @RaghavPal  2 ปีที่แล้ว

      Hi Honey, this can help stackoverflow.com/questions/30426397/how-to-initialize-multiple-restassured-url-in-the-same-project-without-overridin

  • @poojadhamale3874
    @poojadhamale3874 2 ปีที่แล้ว +1

    The type org.hamcrest.Matchers can't be resolved. It is indirectly referenced from required .class file , why I got this error message?

    • @RaghavPal
      @RaghavPal  2 ปีที่แล้ว +1

      Hi Pooja, this can help - stackoverflow.com/questions/46347494/error-as-the-type-org-hamcrest-matcher-cannot-be-resolved
      Do let me know if this resolved your issue

  • @soumendukhilar2043
    @soumendukhilar2043 3 ปีที่แล้ว

    Hi Raghav, How do I verify that the details are added using the POST method. I tried with the Single User GET request mentioned in the website but it gives a blank body as response. Please help.

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว

      Hi Soumendu, are you using the same apis as shown, there can be something missing or incorrect in the request format, check the logs

  • @kushalb.n.4452
    @kushalb.n.4452 3 ปีที่แล้ว

    how to pass array of objects in body ex - [{"id":123,"first_name":"george"},{"id":234,"first_name":"arun"}], can we use jsonobject in this case, any other ways of passing this, also what if body is object of arrays

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว

      Hi Kushal, yes you can do this way or can store in a variable, Can also get this from a file

  • @AmanRaj-lq4je
    @AmanRaj-lq4je 3 ปีที่แล้ว

    Raghav I am working in mindtree... I joined mindtree on 25th jan 2019. We had training for 3 months in SDET.. After that we didnt move to project due to pandemic... They shifter us to support and I got as Service Desk Engineer.. Now can you please help me to tell that is there any chance to come back in SDET in any other company??? Please Raghav , I need your help on this

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว +1

      Hi Aman, yes you already had a basic training, I will suggest to check the current SDET role needs and requirements and skill yourself according to that and start applying

    • @AmanRaj-lq4je
      @AmanRaj-lq4je 3 ปีที่แล้ว

      @@RaghavPal thanks Raghav... That means there is a chance to come back...Thanks for the suggestion..

    • @AmanRaj-lq4je
      @AmanRaj-lq4je 3 ปีที่แล้ว +1

      @@RaghavPal thanks Raghav... That means there is a chance to come back...Thanks for the suggestion..

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว +1

      Yes, absolutely

  • @zahidullaghouri4532
    @zahidullaghouri4532 3 ปีที่แล้ว

    Hey Raghav, i am not able to write equalTo it's giving me an error i've imported everything as you mentioned

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว

      Hi Zahid, the only issue I can think of is either some library mismatch or syntax error

  • @MrManandevil
    @MrManandevil ปีที่แล้ว

    While creating object for JSONOject and printing it out we can see that the sequence is not followed. How to create a json in which sequence is the way that we have specified?

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Hi Manan
      In Rest Assured, the JSON objects are represented using the JsonObject class provided by the JSON library used (such as JSON Simple, Jackson, or Gson). The JSON objects created using these libraries typically do not preserve the order of elements because JSON itself does not guarantee the order.
      If you require a specific order of elements in your JSON, you can use a LinkedHashMap or LinkedHashSet to create your JSON object. These data structures maintain the insertion order of elements.
      Here's an example using JSON Simple library:
      import org.json.simple.JSONObject;
      public class JsonExample {
      public static void main(String[] args) {
      JSONObject json = new JSONObject();
      // Use LinkedHashMap to maintain the order of elements
      LinkedHashMap map = new LinkedHashMap();
      map.put("name", "John");
      map.put("age", "30");
      map.put("city", "New York");
      // Add the elements from the LinkedHashMap to the JSON object
      json.putAll(map);
      // Print the JSON object
      System.out.println(json.toJSONString());
      }
      }
      The output will be:
      {"name":"John","age":"30","city":"New York"}
      By using a LinkedHashMap, you can ensure that the elements are added to the JSON object in the order you specify.

    • @MrManandevil
      @MrManandevil ปีที่แล้ว

      @@RaghavPal Thank you so much

  • @ahmethalukbilgic1985
    @ahmethalukbilgic1985 3 ปีที่แล้ว

    Hi. I give error when i add json to pom.xml "json-simple:1.1.1"not found. Please help

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว

      Can change the lib or ver and try again

  • @poojadhamale3874
    @poojadhamale3874 2 ปีที่แล้ว +1

    When I used equalTo method I got error this method is undefined for type string

    • @RaghavPal
      @RaghavPal  2 ปีที่แล้ว

      Hi Pooja,
      Can you add this import and see if it works
      import static org.hamcrest.Matchers.equalTo;
      stackoverflow.com/questions/49120056/restassured-cant-find-the-equalto-method

    • @poojadhamale3874
      @poojadhamale3874 2 ปีที่แล้ว

      @@RaghavPal after import org.hamcrest.Matchers.equalTo I will get same error message

    • @RaghavPal
      @RaghavPal  2 ปีที่แล้ว

      will need to check more online

  • @sachinmane1391
    @sachinmane1391 3 ปีที่แล้ว

    you didn't explained, what is hashmap and why you used given when and then for post not for put. It will be great if you explain or show what changes you made on record . What is the difference between PUT and POST

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว

      I will try to add a session on this Sachin

  • @leenabharambe3260
    @leenabharambe3260 3 ปีที่แล้ว

    I am getting javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure exception

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว

      hi leena, this can help stackoverflow.com/questions/37714696/not-able-to-connect-to-server-through-java-code-getting-javax-net-ssl-sslhandsh

  • @mhoff-beattraveling2946
    @mhoff-beattraveling2946 2 ปีที่แล้ว

    JSONObject cannot be resolved to a type, why this error msg got ?

    • @RaghavPal
      @RaghavPal  2 ปีที่แล้ว

      it may either be due to some library missing or some syntax/structure issue
      Please check if you have imported all the correct libraries and then compare the code,
      Can check some examples online

  • @krunalidedhia7117
    @krunalidedhia7117 ปีที่แล้ว

    how do script when i want to take response from post api and send it to put api

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว +1

      Hi Krunali
      Here is an example of how to take the response from a POST API and send it to a PUT API using Rest Assured:
      ```java
      import org.hamcrest.Matchers;
      import org.junit.jupiter.api.Test;
      import io.restassured.RestAssured;
      import io.restassured.response.Response;
      public class RestAssuredExample {
      @Test
      public void testPostAndPut() {
      // Create a POST request to the /products API.
      Response postResponse = RestAssured.given()
      .contentType("application/json")
      .body("{ \"name\": \"Product 1\" }")
      .post("/products");
      // Assert that the POST request was successful.
      postResponse.then().statusCode(201);
      // Get the product ID from the POST response.
      String productId = postResponse.jsonPath().get("id");
      // Create a PUT request to the /products/productId API.
      Response putResponse = RestAssured.given()
      .contentType("application/json")
      .body("{ \"name\": \"Product 2\" }")
      .put("/products/" + productId);
      // Assert that the PUT request was successful.
      putResponse.then().statusCode(200);
      // Assert that the product name was updated.
      putResponse.then().body("name", Matchers.equalTo("Product 2"));
      }
      }
      ```
      In this example, we first create a POST request to the /products API. We pass in a JSON payload that contains the name of the product. We then assert that the POST request was successful.
      We then get the product ID from the POST response. We use this product ID to create a PUT request to the /products/productId API. We pass in a JSON payload that contains the new name of the product. We then assert that the PUT request was successful.
      Finally, we assert that the product name was updated.
      I hope this helps

    • @krunalidedhia7117
      @krunalidedhia7117 ปีที่แล้ว

      Thank you sir.! I am trying this method@@RaghavPal

  • @mani36526
    @mani36526 ปีที่แล้ว

    Has items giving me error that the method hasitem is undefined, you didn't get this error
    Please help me to resolve this

    • @RaghavPal
      @RaghavPal  ปีที่แล้ว

      Hi Manisha, will need more details and context on this

  • @andreytravkin7579
    @andreytravkin7579 3 ปีที่แล้ว

    When I trying to create response: "JSONPObject request = new JSONPObject(map);
    I've get the error: "JSONPObject request = new JSONPObject(map);"
    Does anybody know how to fix it?

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว

      Hi Andrey, what is the error log

  • @yazh403
    @yazh403 3 ปีที่แล้ว

    Mobile testing ku video podalaiya

    • @RaghavPal
      @RaghavPal  3 ปีที่แล้ว

      I will make on this

  • @andyrockstar78
    @andyrockstar78 หลายเดือนก่อน

    Getting this error when trying to run GET. groovy

    • @RaghavPal
      @RaghavPal  หลายเดือนก่อน

      Andy
      will need more details, your steps, code etc

    • @andyrockstar78
      @andyrockstar78 หลายเดือนก่อน

      @@RaghavPal not able to post screenshots

    • @RaghavPal
      @RaghavPal  หลายเดือนก่อน

      can upload on some sharing sites like WeTransfer and give me the link with details