REST Assured Beginner Tutorial 7 | PUT PATCH DELETE
ฝัง
- เผยแพร่เมื่อ 22 ต.ค. 2024
- Raghav's mission - automationstep...
In this tutorial, we will learn from scratch how to create and run Put, Patch and Delete API Requests in Rest Assured test automation framework
Join Automation Step By Step channel: www.youtube.co...
Every LIKE & SUBSCRIPTION gives me great motivation to keep working for you
#RestAssuredBeginnerTutorials
REST Assured website - rest-assured.io/
You can support my mission for education by sharing this knowledge and helping as many people as you can
If my work has helped you, consider helping any animal near you, in any way you can.
_______ ONLINE COURSES TO LEARN _______
Udemy Discounts - automationstep...
GitHub - github.com/Rag...
Udemy - www.udemy.com/...
Training by Raghav at your venue - raghav.qna@gmail.com
Training schedule - automationstep...
----------- UI TESTING -----------
Selenium Beginners - bit.ly/2MGRS8K
Selenium Java Framework from Scratch - bit.ly/2N9xvR6
Selenium Python - bit.ly/2oyMp5x
Selenium Tips - bit.ly/2owxc50
Selenium Builder - bit.ly/2MKNtlq
Katalon Studio - bit.ly/2wARFdi
Robot Framework with RIDE- bit.ly/2Px6Ue9
Robot Framework with Eclipse - bit.ly/2N8DZxb
Protractor - bit.ly/2KtqVkU
TestProject - bit.ly/2DRNJYE
----------- API TESTING -----------
Web Services (API) - bit.ly/2MGafL7
SoapUI - bit.ly/2MGahmd
Postman - bit.ly/2wz8LrW
General - bit.ly/2PYdwmV
Katalon Studio API Testing - bit.ly/2BwuCTN
----------- MOBILE TESTING -----------
Appium - bit.ly/2ZHFSGX
Mobile Playlist - bit.ly/2PxpeUv
----------- CI | CD | DEVOPS -----------
Jenkins Beginner - bit.ly/2MIn8EC
Jenkins Tips & Trick - bit.ly/2LRt6xC
Docker - bit.ly/2MInnzx
Kubernetes - bit.ly/2MJIlMK
------------VIRTUALISATION------------
Virtualization on windows - bit.ly/2SItIL9
----------- VERSION CONTROL SYSTEM -----------
Git & GitHub - bit.ly/2Q1pagY
GitLab - bit.ly/2kQPGyQ
----------- PERFORMANCE TESTING -----------
JMeter Beginner - bit.ly/2oBbtIU
JMeter Intermediate - bit.ly/2oziNVB
JMeter Advanced - bit.ly/2Q22Y6a
JMeter Tips & Tricks - bit.ly/2NOfWD2
Performance Testing - bit.ly/2wEXbLS
----------- PROGRAMMING -----------
Java Beginners - bit.ly/2PVUcXs
Java Tips & Tricks - bit.ly/2CdcDnJ
GROOVY - bit.ly/2FvWV5C
JAVASCRIPT - bit.ly/2KJDZ8o
PYTHON - bit.ly/2Z4iRye
----------- IDE -----------
Visual Studio Code - bit.ly/2V15yvt
----------- BUILD TOOLS -----------
Maven - bit.ly/2NJdDRS
Gradle - bit.ly/30l3h1B
----------- OTHERS -----------
Redis- bit.ly/2N9jyCG
Misc - bit.ly/2Q2q5xQ
Tools & Tips - bit.ly/2oBfwoR
QnA Friday- bit.ly/2NgwGpw
Sunday Special - bit.ly/2wB23BO
Ask Raghav - bit.ly/2CoJGWf
Interviews - bit.ly/2NIPPxk
All Playlists - bit.ly/2LSiezA
---------- Connect with Raghav -----------
Website - automationstep...
Udemy Courses - automationstep...
TH-cam - / automationstepbystep
Please share this knowledge with everyone
If my work has helped you consider helping an animal near you in any ways you can
Never Stop Learning
Raghav
Thanks Raghav, your sessions are easy to understand and value addition to us. One query what is the difference between PATCH and PUT both are used for update so what is the difference
Hi Soumya, PUT is to update or modify entire resource whereas PATCH is to do a small update on the resource. Often, they can be used interchageably
True passion!! @Automation Step by Step - Raghav Pal.
Thanks a lot
Hello Raghav
This series is really helpful
Is this enough crack the rest assured interview experienced candidate?
Yes Yashaswi, if you follow the complete lecture with hands-on and understand the concept, it is enough
Thankyou Raghav, I appreciate the clear and easy-to-follow videos you provide. As a beginner with minimal coding experience, they have been extremely beneficial. May I kindly request your guidance on how to maintain and improve my skills, particularly with regards to RestAssured, Java, and Postman? I am concerned about losing proficiency if not consistently practicing and would greatly appreciate any suggestions for opportunities to put my skills to the test.
Hi Nikita,
Practice regularly: Set aside some time each week to practice what you have learned. Write small applications and test cases to keep your skills sharp.
Keep adding new skills
Follow tutorials with hands-on
Join online communities: Join online communities such as forums, discussion groups, and social media groups related to RestAssured, Java, and Postman. Engage with other professionals and learn from their experiences.
Participate in coding challenges
Collaborate with peers
Contribute to open source projects:
@@RaghavPal Wonderful suggestion, I will certainly do my best to implement it.
Hello, Can you please tell us what is the structure of the classes should be done so I can make it easy if I am going to test several APIs? is it going to be one class containing several test methods each for one api? or it is going to be several classes? like a class for requests of each api and a class to test and assert?
Hi Asmaa, good question, so generally it depends on your project and needs of the app, For e.g. you have different scenarios like Login, Product, Registration etc. you may want to have these housed together in categories, Like one folder and multiple classes for the related scenarios. So every section has a individual folder and multiple classes for diff use-cases of that section (scenario)
You can also create a class for every API having all its possible methods. And in the scenario class can call the api's as required.
Raghav i have one doubt, the knowledge that i am getting from these series is enough to say that i have very good knowledge in RestAssured....
Yes, if you follow with hands-on
really amazing tutorials.thanks bro
Most welcome Hazim
Thanks Raghav Can you please make a video on how to handle .pfx certificate in rest assured
Hi Varsha, I will check on this
Hi Raghav,
If I have 2 global verible with same name and same value in postman, which one will script use while executing.. the question regarding postman concepts
Hi Shwetha, Before I answer 2 things just for easy communication.
1. Pls post your comment in the relevant video only, so it helps others in future
2. Adding duplicate comments on multiple videos will not help as I can see all the comments on all the videos on a single page, So for me it is too many duplicate comments.
Coming to your Question:
ideally this should not be allowed, but I know you can create global variables with same name. When you refer the variable created last will be referred.
Now logically speaking, if you have the variable with same name & value, when you call or refer the variable, it will anyways not matter which variable is getting called as you will get the same value,
Raghav..one doubt..are you covering rest assured framework during end of rest assured series?
Hi Suresh, I did not get you properly, this is the complete series on REST assured framework, Can check all the course from here - automationstepbystep.com/
How to use PATCH in java with form-data, like in Postman we are selecting Body, form-data then Key and Value
Hi Shivakar,
To send a PATCH request with form-data in Java, you can use the HttpURLConnection class to create the connection and set the request properties. Here's an example code snippet that shows how to do this:
import java.io.*;
import java.net.*;
public class PatchWithFormDataExample {
public static void main(String[] args) throws Exception {
// Create connection
URL url = new URL("example.com/api/resource");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("PATCH");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Authorization", "Bearer token");
// Set form data
String formData = "key1=value1&key2=value2";
connection.setDoOutput(true);
OutputStream outputStream = connection.getOutputStream();
outputStream.write(formData.getBytes());
outputStream.flush();
outputStream.close();
// Get response
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
StringBuilder response = new StringBuilder();
while ((line = reader.readLine()) != null) {
response.append(line);
}
reader.close();
// Print response
System.out.println(response.toString());
}
}
In this example, we first create a URL object with the API endpoint we want to send the PATCH request to. Then, we open a HttpURLConnection with the openConnection() method and set the request method to PATCH. We also set the Content-Type header to application/x-www-form-urlencoded and add an Authorization header with a bearer token.
Next, we set the form data using the setDoOutput(true) method to indicate that we want to write data to the connection. We then get an output stream from the connection using the getOutputStream() method and write the form data to the output stream using the write() method.
Finally, we get the response from the server by reading from the input stream of the connection using a BufferedReader, and we print the response to the console.
Note that in this example, we are sending the form data as a string in the format key1=value1&key2=value2. You may need to adjust the format of the form data depending on the requirements of the API you are using.
Please do check about the Card Matching Helper and guide me how to install it..... whenever you get time
will check on that Mohit
@@RaghavPal ohk thanks...will w8 for your reply
is 301 for testPatch() method is fine? my program is giving 301 instead of 200. Please help me with this.
301 is for moved permanently, you can check what is the new URI. www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
@@RaghavPal Thank You
Tutorial is very good and easy to understand, but given().methods are giving errors ,, I tried importing packages, however it is not helping. Could you please provide solution?
Hi Anjali,
The "given().methods" in Rest Assured are part of the fluent API, which is used to set up the request before sending it. If you are getting errors when using the "given().methods", it is likely that there is a problem with your imports or configuration.
Here are a few things to check:
Make sure you have the latest version of Rest Assured and its dependencies. You can check this by looking at the POM.xml file or by running the command "mvn dependency:tree" in the command prompt.
Ensure that you have imported the correct package for the "given()" method. The package should be "io.restassured.builder.RequestSpecBuilder"
Make sure that you have imported "io.restassured" package, it is the root package of rest-assured and contains all the classes and interfaces required to use rest-assured.
If you're still facing issues, try to import the following:
import static io.restassured.RestAssured.*;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
Hi Raghav How i Add If else condition in my code to validate request and response?
Hi Priyank, I will plan a session, for now can see some examples online
@@RaghavPal Thanks Raghav thanks for your reply I am waiting for that 👍
@raghav how to achieve parallel testing
I will add a session
In Video, we have seen the results in console that we are doing PUT , PATCH, DELETE using fake Rest API in net...Cant we see that is Updated , deleted or not in fake API in net?
Hi Daniel, yes you can do and check
Can we generate extent report pdf with qaf framework ?.I tried a lot it is not working
not very sure, will need to check on this
parallel testing helpme
Sure will add a session
put and patch is not working,it shows 200 OK,that is wrong.
will check, can try with some other APIs