Implement HTTP PUT method

9 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€46.41
List Price:  €64.98
You save:  €18.57
£39.74
List Price:  £55.64
You save:  £15.89
CA$68.36
List Price:  CA$95.72
You save:  CA$27.35
A$75.43
List Price:  A$105.61
You save:  A$30.18
S$67.50
List Price:  S$94.51
You save:  S$27
HK$390.66
List Price:  HK$546.96
You save:  HK$156.29
CHF 45.28
List Price:  CHF 63.39
You save:  CHF 18.11
NOK kr542.32
List Price:  NOK kr759.29
You save:  NOK kr216.97
DKK kr346.21
List Price:  DKK kr484.72
You save:  DKK kr138.51
NZ$83.04
List Price:  NZ$116.27
You save:  NZ$33.22
د.إ183.60
List Price:  د.إ257.06
You save:  د.إ73.45
৳5,477.48
List Price:  ৳7,668.91
You save:  ৳2,191.43
₹4,173.46
List Price:  ₹5,843.17
You save:  ₹1,669.71
RM236.90
List Price:  RM331.68
You save:  RM94.78
₦61,737.65
List Price:  ₦86,437.65
You save:  ₦24,700
₨13,884.75
List Price:  ₨19,439.77
You save:  ₨5,555.01
฿1,836.53
List Price:  ฿2,571.29
You save:  ฿734.76
₺1,613.79
List Price:  ₺2,259.44
You save:  ₺645.64
B$253.58
List Price:  B$355.04
You save:  B$101.45
R921.65
List Price:  R1,290.39
You save:  R368.73
Лв90.79
List Price:  Лв127.12
You save:  Лв36.32
₩67,757.86
List Price:  ₩94,866.43
You save:  ₩27,108.56
₪187.05
List Price:  ₪261.89
You save:  ₪74.83
₱2,856.96
List Price:  ₱3,999.98
You save:  ₱1,143.01
¥7,687.37
List Price:  ¥10,762.93
You save:  ¥3,075.56
MX$846.40
List Price:  MX$1,185.03
You save:  MX$338.62
QR182.04
List Price:  QR254.87
You save:  QR72.83
P679.94
List Price:  P951.97
You save:  P272.03
KSh6,711.15
List Price:  KSh9,396.15
You save:  KSh2,685
E£2,396.98
List Price:  E£3,355.96
You save:  E£958.98
ብር2,864.89
List Price:  ብር4,011.08
You save:  ብር1,146.18
Kz41,759.31
List Price:  Kz58,466.37
You save:  Kz16,707.06
CLP$47,049.08
List Price:  CLP$65,872.48
You save:  CLP$18,823.40
CN¥353.90
List Price:  CN¥495.49
You save:  CN¥141.59
RD$2,900.17
List Price:  RD$4,060.47
You save:  RD$1,160.30
DA6,724.18
List Price:  DA9,414.39
You save:  DA2,690.21
FJ$112.18
List Price:  FJ$157.07
You save:  FJ$44.88
Q387.94
List Price:  Q543.15
You save:  Q155.20
GY$10,441.17
List Price:  GY$14,618.48
You save:  GY$4,177.30
ISK kr6,976.60
List Price:  ISK kr9,767.80
You save:  ISK kr2,791.20
DH503.40
List Price:  DH704.80
You save:  DH201.40
L884.08
List Price:  L1,237.78
You save:  L353.70
ден2,857.75
List Price:  ден4,001.09
You save:  ден1,143.33
MOP$401.71
List Price:  MOP$562.43
You save:  MOP$160.71
N$923.86
List Price:  N$1,293.49
You save:  N$369.62
C$1,837.28
List Price:  C$2,572.34
You save:  C$735.06
रु6,663.84
List Price:  रु9,329.91
You save:  रु2,666.07
S/186.31
List Price:  S/260.85
You save:  S/74.53
K192.92
List Price:  K270.11
You save:  K77.18
SAR187.49
List Price:  SAR262.50
You save:  SAR75.01
ZK1,346.25
List Price:  ZK1,884.87
You save:  ZK538.61
L230.87
List Price:  L323.24
You save:  L92.36
Kč1,161.41
List Price:  Kč1,626.08
You save:  Kč464.66
Ft18,082.13
List Price:  Ft25,316.43
You save:  Ft7,234.30
SEK kr541.20
List Price:  SEK kr757.73
You save:  SEK kr216.52
ARS$43,928.30
List Price:  ARS$61,503.14
You save:  ARS$17,574.83
Bs345.62
List Price:  Bs483.90
You save:  Bs138.27
COP$194,235.29
List Price:  COP$271,944.94
You save:  COP$77,709.65
₡25,508.30
List Price:  ₡35,713.67
You save:  ₡10,205.36
L1,232.91
List Price:  L1,726.17
You save:  L493.26
₲373,633.39
List Price:  ₲523,116.65
You save:  ₲149,483.25
$U1,909.79
List Price:  $U2,673.86
You save:  $U764.07
zł200.70
List Price:  zł281
You save:  zł80.29
Already have an account? Log In

Transcript

Hello guys, welcome to the SU one tutorial so the US we don't have VBA In this lesson we will establish the put request to update the our database record in the IRS for minor. For this we need to switch to Visual Studio and create a new method or axon port which take the ID from the parameter a new product detail from a body click the try catch block. First of all we need to retrieve the original item from the database for that given ID. For this we need to write the same code that we are using the get parameter ID Method started with the using statement product entities dt equal to new product entity rotor axis thing for call to action and duties toward production or for strategy for x such that x dot product ID quality cool near you and it Via parameter and update the existing product.

Name with the new product. Name Sam quarter for the auto properties true is equal to a new product dot price for the chart quantity Korto new product dot quantity, existing product or box size or to a new product walk sighs And we need to save the changes. And it is dot Save Changes. And we need to run it let's copy the URL switch to postman plugin. Here's the URL right the API slash or controller name. That is a product and click on the SN to the to all of the exit data.

You can see that the product ID eight that is a marker, which block size is 10 and the price is 30. I'm going to sanebox I should find one price to the 24 that we need to Copy the JSON format. Choose the output method, specify the ID in the parameter. Click on the body and specify the AIDS content. Remove the ID upgrade to the file and 20 click on the send button. You can see that it it status is a 204 that is no content that's red or the our database.

You can see that the box sizes a file as well as the prices change to the 20. We have successfully updated the our database. But India certain situation it throws the exception when the product does not exist in the database. For that, we need to handle it. And we also need to send the proper shaders that is a 404 product not found. And when the product is updated, we need to send the orchestrators.

Let's do it. First of all we need to check that the product is accessing the our database or not. Or that we need to check whether the product is null then we need to return a request dot could you add a response with the HTTP status code? Not found that is 404. And with the proper message, product with the UN ID does not exist we also want to chain the Overton type to the TTP response message. If the product does not exist then it will written this message with the not found status code empty it exists, it will update the database and and we also need to send the proper status code that is okay for that to any good idea return request door could you response with the HTTP status code?

Okay. A product that is existing product, not the new product. And when they accept Sonico, we need to put it on the request or create error response with the TTP status code. Bad request and your idea and pass the our exception object. Right click on the run button. Let's switch to postman plugin and this time we are going to update the box size to then click on the send button.

You can see that it written status code 200 that is okay and the new product object details that is product IDs eight and the details. Let's quick check to SQL Server, we can see that the box sizes 10 to 10. Less shy to update the product that does not exist. For example, we are assuming that the product with the egg you and it does not exist messes with the status quo for zero for this is the code for the put request. First of all we need to showing the exit product detail and check whether the product is exists or not if not exist, then we need to return the 404 status. Otherwise, update the product detail and DSL changes and return the keys to the score otherwise Return the Barefoot Crash Course.

Thanks for watching. If you have any doubt, feel free to contact me

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.