Postman Beginner Tutorial 4 | PUT PATCH API Request
Вставка
- Опубліковано 27 сер 2024
- All FREE courses - automationstep...
Notes:
How to add PUT & PATCH API Request
Run and check Response
#Postman #APITesting
____________________________________________________________
Stories by Raghav - automationstep...
My Udemy Courses - automationstep...
Every LIKE & SUBSCRIPTION gives me great motivation to keep working for you
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 _______
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 -----------
Udemy Courses - www.udemy.com/...
Twitter - / learnwithraghav
UA-cam - / automationstepbystep
Never Stop Learning
Raghav
Raghav , Can you imagine how many students have been inspired by you ? I like the way your video ends with Never stop leaning ! Thank you for your hard work
So nice of you Aylin
Aylin I think you meant "inspired" and not "expired". :)
@@akhil100 You are right . I just corrected
Hello Sir..Thank You So much for sharing video on postman. But plz share next video early so we can go fast .. thank you.
I will try Anjuli
Amazing tutorial. Greetings from Brazil!!
Glad you liked it Marcio
Nice video, now understood the importance between post and put
Thanks Raghav
Glad it was helpful Prasad
Great explanation with user friendly tools👍
Glad it was helpful Sonu
Hello, Sir thank you so much for sharing these videos, it will be really helpful for us.
So nice of you Gayatri
Very clear and at a good pace video.
Well done.
Thanks a lot
Thank you Raghav 😊
So nice of you
Jio bhai Great explanation 😊
Thanks a lot
Thanks for the awesome video, Raghav sir ! However I could not understand exactly here what is the difference b/w PUT & PATCH bcoz I am able to change the data partially with PATCH too...I believe it would be clarified in next videos...The way you explain is just awesome....Hats off to you !
I will add more on this Jatin... keep watching
Good Explanation bro
Thanks a lot Lakshmi
Hi Raghav, if I want to update partially.... PUT works in that case too so could you pls elaborate more on the difference between patch n put with examples
Hi Prerna, sure I will add a video on this, I recently created a community post for it, Can find it here - ua-cam.com/channels/Tt7pyY-o0eltq14glaG5dg.htmlcommunity
@@RaghavPal thanks Raghav... Will check
Hi Raghav, Thanks for posting the video. Can you give more clarity b'n Put and Patch requests?
Amarnath
The PUT and PATCH HTTP methods are both used to update resources, but they differ in how they do it.
*PUT* sends the entire resource to the server, replacing the existing resource with the new one.
*PATCH* sends a partial representation of the resource to the server, which is then used to update the existing resource.
So PUT replaces the resource
PATCH updates the resource (partially or completely)
*Which method to use depends on the specific needs of your application.* If you need to update the entire resource, then you should use PUT. If you only need to update a portion of the resource, then you should use PATCH.
*Here are some general guidelines for choosing between PUT and PATCH:*
* Use PUT if you need to update the entire resource.
* Use PATCH if you only need to update a portion of the resource.
* Use PUT if you want to ensure that the resource is in a consistent state after the update.
* Use PATCH if you want to allow the client to update the resource without having to know the entire state of the resource.
Thanks for the video, sir. But couldn't get any difference between PUT and PATCH!
Hi Yash,
Sure, I can explain the difference between PUT and PATCH in easy language with an example!
Imagine you have a toy car that you want to customize. You can change its color, add stickers, or modify its shape.
In the context of web development, PUT and PATCH are two methods that are used to modify resources on a web server.
PUT is like replacing the entire toy car with a new one. If you use PUT to modify a resource, you must send the complete representation of that resource to the server. This means that if you want to change a single attribute of the resource, you need to send the entire resource with the new attribute value.
For example, if you have a toy car resource with attributes like "color," "sticker," and "shape," and you want to change the color of the car, you would need to send the entire toy car resource with the new color attribute value using the PUT method.
On the other hand, PATCH is like modifying the toy car piece by piece. With PATCH, you can modify specific attributes of a resource without sending the entire representation of that resource to the server. This makes PATCH more efficient than PUT for making small changes.
For example, if you want to change only the color of the toy car using the PATCH method, you can send a request to the server with just the new color attribute value, without including the entire toy car resource.
In summary, PUT is used to completely replace a resource, while PATCH is used to make partial modifications to a resource
Saved me brother! Thank you :D
Most welcome
thank you sir!
Most welcome Justine
But the PATCH method also changed the whole object in your example. Shouldn't there still be job in the result in patch method?
This may be the case as these are dummy APIs we are using for demo
Hi raghav, i have doubt first i performed get operation to get all users(have first name is kalpana and id is 1) after i performed put operation that body has first name is rakesh who have id is 1.Next time i performed get operation that firstname will be updated or not who have id=1 ??
Kalpana
Yes, if you perform a GET operation to get all users with the first name "Kalpana" and ID 1, and then perform a PUT operation to update the first name of the user with ID 1 to "Rakesh", the next time you perform a GET operation, the first name of the user with ID 1 will be "Rakesh". This is because the PUT operation updates the data on the server, and the GET operation retrieves the updated data from the server.
Here's a more detailed explanation of how these operations work:
**GET Operation:** The GET operation is used to retrieve data from a server. When you perform a GET operation, the server sends you back the current state of the data. In this case, you are performing a GET operation to retrieve all users with the first name "Kalpana" and ID 1. The server will send you back a JSON object with the following data:
```json
{
"id": 1,
"firstName": "Kalpana"
}
```
**PUT Operation:** The PUT operation is used to update data on a server. When you perform a PUT operation, you send the server a JSON object with the new data. In this case, you are performing a PUT operation to update the first name of the user with ID 1 to "Rakesh". The server will update the data on its end, and then send you back a JSON object with the following data:
```json
{
"id": 1,
"firstName": "Rakesh"
}
```
**Subsequent GET Operations:** The next time you perform a GET operation to retrieve all users with the first name "Kalpana" and ID 1, the server will send you back the JSON object with the updated data:
```json
{
"id": 1,
"firstName": "Rakesh"
}
```
This is because the PUT operation updated the data on the server, and the GET operation is retrieving the updated data from the server.
Which tool you are using for highlighting something on screen? Like during video you highlight some sections with red bordered triangle etc
It's screen annotation tools
Authentication token need to pass as cookie. Cookie name is “token” and value is generated auth token. ‘Cookie: token=’. HOW TO DO THIS - STEPS
Hi Chinmay
Sure, here are the steps on how to pass an authentication token as a cookie in Postman:
1. Open the Postman app and create a new request.
2. In the Request tab, enter the URL of the API that you want to authenticate with.
3. In the Headers tab, click on the **Cookies** tab.
4. Click on the **Add Cookie** button.
5. In the **Name** field, enter the name of the cookie, which is "token" in this case.
6. In the **Value** field, enter the value of the cookie, which is the generated auth token.
7. Click on the **Save** button.
8. Click on the **Send** button to send the request.
The API should now be authenticated with the generated auth token.
Here are some additional tips for passing authentication tokens as cookies in Postman:
* You can also use the **Authorization** tab to pass authentication tokens. The **Authorization** tab allows you to select different types of authentication, such as Basic Auth, Bearer Auth, and OAuth.
* You can use the **Variables** feature in Postman to store authentication tokens. This can be useful if you need to use the same authentication token for multiple requests.
* You can use the **Collection Runner** feature in Postman to run a collection of requests that all use the same authentication token. This can be useful for automating tasks that require authentication
What about updating an index of array? I get out of bound exception if i go as per docs
will need to check the scripts and logs
Could you please tell me how you got to the Rest Request at time 1:16, showing the resources we can use?
Hi Mike, it is a demo rest service available here - thomas-bayer.com/sqlrest
Sir, when i tried to do the put in the exact way you do, in repose, i could see only "updated at..." Why iam not getting name amd job? Please help
its demo sample APIs, may have changed
Is there no test to do at the end?
Ammar
Have covered Tests in a separate session.
I am using postman to test my rest api PUT request against the app created on STS 4 spring boot framework. I am getting this error:
Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: No acceptable representation]
client content type raw JSON. I understand that once the client and server are both using compatible media types, the HttpMediaTypeNotAcceptableException should no longer occur and the response should be returned successfully. How do I fix it? Thanks
Hi Javed,
The error you're seeing (HttpMediaTypeNotAcceptableException) typically occurs when the server is unable to provide a response in a format that the client can accept. This means that the client and server are not using compatible media types, as you correctly noted.
To fix this error, you'll need to ensure that the client and server are both using compatible media types. Here are a few steps you can take to troubleshoot and resolve this issue:
Check the request headers: In your Postman request, make sure that the Content-Type header is set to application/json. This tells the server that the request body is in JSON format.
Check the response headers: In the server response, make sure that the Content-Type header is set to a format that the client can accept. If the client is expecting JSON, the Content-Type header should be set to application/json. You can set this header in your Spring Boot application by adding the produces attribute to your @RequestMapping annotation, like this:
@RequestMapping(value = "/your-endpoint", method = RequestMethod.PUT, produces = "application/json")
Check the response body: Make sure that the response body is actually in the format specified by the Content-Type header. If the Content-Type header is set to application/json, the response body should be a valid JSON string.
Check the server logs: If the above steps don't help, check the logs of your Spring Boot application to see if there are any additional error messages that might help you diagnose the problem.
By following these steps, you should be able to identify and fix the issue causing the HttpMediaTypeNotAcceptableException error.
Hi Raghav, what if I want to use PATCH on an API but I don't know the record ID but I already know the user_name for example? How can I apply the PATCH command in this example? Thanks.
Hi Dante, It will depend on your APIs, basically for a PATCH we need to point to the exact resource, whatever way you can in an API, whether it is through any unique value, like ID, Name or some combination
Please add video including HEAD ,TRACE AND OPTION METHOD.
Sure Vipin, will plan to add
With practical examples.
ok
What happens if we use PATCH to update both name and Job. Is that not similar to PUT?
Hi Siva,
Patch - update some information of the resource
Put - replace the resource
Please if I want to use patch request on all data in the api how do I do it?
will need to see some example Victor
you did not explain why we need patch when we can do same in post
Ravi
Both methods serve different purposes:
- POST: This method is used to create a new resource or submit data to the server. When you send a POST request, you're asking the server to accept the data enclosed in the body of the request and use it to create a new object. It's like adding a new file to a folder.
- PATCH: This method is used for making partial updates to an existing resource. If you only need to update a few fields of a resource, PATCH is more appropriate. It's like editing a few words in a sentence without rewriting the whole page.
Here's why you might choose PATCH over POST for updates:
- Efficiency: PATCH requests only send the changes, rather than the entire updated entity, which can be more efficient for both bandwidth and processing.
- Clarity: Using PATCH makes it clear that you're updating a resource rather than creating a new one.
- Control: PATCH provides finer control over the update process, allowing partial updates and potentially reducing conflicts when multiple clients are modifying the same resource.
In summary, while POST can be used for updates in some cases, PATCH is specifically designed for partial updates and can be more suitable for that purpose
.
Hello sir. I am getting "403 forbidden" error on calling 'put' method. Why is it happening?
Hi Muneeb, you api may be needing some authorization, pls check or try with a diff api
Is this course for API testing or developing the API?
Testing API
you have not shown post in intellij
I will check
how to create own api?????
Check this - ua-cam.com/video/7vx0RIwHVzg/v-deo.html
tytytyty
Most welcome ..