Versioning using URI

11 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
€44.28
List Price:  €62
You save:  €17.71
£37.69
List Price:  £52.77
You save:  £15.07
CA$69.36
List Price:  CA$97.11
You save:  CA$27.75
A$77.89
List Price:  A$109.06
You save:  A$31.16
S$64.83
List Price:  S$90.77
You save:  S$25.93
HK$388.52
List Price:  HK$543.96
You save:  HK$155.44
CHF 41.29
List Price:  CHF 57.81
You save:  CHF 16.52
NOK kr517.46
List Price:  NOK kr724.48
You save:  NOK kr207.02
DKK kr330.41
List Price:  DKK kr462.61
You save:  DKK kr132.19
NZ$84.33
List Price:  NZ$118.07
You save:  NZ$33.73
د.إ183.61
List Price:  د.إ257.07
You save:  د.إ73.45
৳6,093.85
List Price:  ৳8,531.88
You save:  ৳2,438.02
₹4,279.31
List Price:  ₹5,991.37
You save:  ₹1,712.06
RM213.95
List Price:  RM299.55
You save:  RM85.60
₦80,461.90
List Price:  ₦112,653.10
You save:  ₦32,191.20
₨14,092.14
List Price:  ₨19,730.13
You save:  ₨5,637.98
฿1,640.99
List Price:  ฿2,297.52
You save:  ฿656.53
₺1,931.55
List Price:  ₺2,704.32
You save:  ₺772.77
B$287.18
List Price:  B$402.08
You save:  B$114.89
R909.03
List Price:  R1,272.71
You save:  R363.68
Лв86.35
List Price:  Лв120.90
You save:  Лв34.55
₩70,054.36
List Price:  ₩98,081.71
You save:  ₩28,027.35
₪178.84
List Price:  ₪250.39
You save:  ₪71.55
₱2,781.34
List Price:  ₱3,894.10
You save:  ₱1,112.75
¥7,237.95
List Price:  ¥10,133.71
You save:  ¥2,895.76
MX$978.72
List Price:  MX$1,370.29
You save:  MX$391.56
QR182.01
List Price:  QR254.83
You save:  QR72.82
P680.79
List Price:  P953.17
You save:  P272.37
KSh6,466.20
List Price:  KSh9,053.20
You save:  KSh2,587
E£2,531.30
List Price:  E£3,544.03
You save:  E£1,012.72
ብር6,728.99
List Price:  ብር9,421.13
You save:  ብር2,692.13
Kz45,590.88
List Price:  Kz63,830.88
You save:  Kz18,240
CLP$47,282.04
List Price:  CLP$66,198.64
You save:  CLP$18,916.60
CN¥361.19
List Price:  CN¥505.70
You save:  CN¥144.50
RD$2,951.01
List Price:  RD$4,131.65
You save:  RD$1,180.64
DA6,645.59
List Price:  DA9,304.36
You save:  DA2,658.77
FJ$112.92
List Price:  FJ$158.10
You save:  FJ$45.17
Q385.11
List Price:  Q539.19
You save:  Q154.07
GY$10,461.12
List Price:  GY$14,646.40
You save:  GY$4,185.28
ISK kr6,488.20
List Price:  ISK kr9,084
You save:  ISK kr2,595.80
DH463.01
List Price:  DH648.26
You save:  DH185.24
L854.60
List Price:  L1,196.51
You save:  L341.91
ден2,708.52
List Price:  ден3,792.14
You save:  ден1,083.62
MOP$400.55
List Price:  MOP$560.81
You save:  MOP$160.25
N$933.50
List Price:  N$1,306.98
You save:  N$373.47
C$1,845.09
List Price:  C$2,583.28
You save:  C$738.18
रु6,780.01
List Price:  रु9,492.56
You save:  रु2,712.54
S/183.84
List Price:  S/257.39
You save:  S/73.55
K202.87
List Price:  K284.03
You save:  K81.16
SAR187.50
List Price:  SAR262.52
You save:  SAR75.01
ZK1,390.76
List Price:  ZK1,947.17
You save:  ZK556.41
L226.88
List Price:  L317.66
You save:  L90.77
Kč1,104.43
List Price:  Kč1,546.29
You save:  Kč441.86
Ft17,977.93
List Price:  Ft25,170.54
You save:  Ft7,192.61
SEK kr483.06
List Price:  SEK kr676.33
You save:  SEK kr193.26
ARS$57,238.04
List Price:  ARS$80,137.84
You save:  ARS$22,899.79
Bs346.56
List Price:  Bs485.21
You save:  Bs138.65
COP$216,579.55
List Price:  COP$303,228.71
You save:  COP$86,649.15
₡25,326.52
List Price:  ₡35,459.16
You save:  ₡10,132.63
L1,301.19
List Price:  L1,821.77
You save:  L520.58
₲401,593.41
List Price:  ₲562,262.91
You save:  ₲160,669.49
$U2,088.44
List Price:  $U2,923.98
You save:  $U835.54
zł189.06
List Price:  zł264.70
You save:  zł75.64
Already have an account? Log In

Transcript

Hello guys, welcome to the 26th session or the SP dotnet Web API. In this session, we will learn how towards an end our API using the UI. The first question arises that what is worsening when our API probably is many client are going to use it. If we need to make the changes in iOS 10, it will reflect to the all of the inclined to solve this, we are creating the various version of the API. There are several way to creating the versioning in our API, we can create our signing using the UI accept header words on hitter media type as well as the query string. In this lesson, we are going to use the versioning using the Ura.

Let's switch to the Visual Studio. I'm created a new VBA project in which add a new model off name employee v1 The ShareFile version one and within these, I'm going to create a public integer ID property that public string name. Yeah Then set and now going to create a new controller, new controller or to VBA to empty off name, employee we won. Within that we need to create a static list of employee version One add the namespace all employees equal to new list of employees. Within that we are going to create a new instance of the employee version one with the dummy data is equal to one name equal to new ly employee ID equal to name equal to Ravi. One more child equal to three and named Makoto.

So come and see me semicolon After that creating a get method public enumerable of employee words and one get within that window just written the all employees and another method for receiving the insurance or the employee or someone within that we are providing the ID and we need to return all employees door pushed or before an employee such that employee.id will require them don't hide in a parameter Let's see how we are going to route menus of idpa slash v1 slash employee then we need to return the list of the all the employees. And when he was a fire the APS last we went to last employee slash ID, then we need to return the employee with Diego ID. When the user use the v2 instead of the v1, then we need to perform the all of those operations on the v2 insurance. There are two way for providing the versioning.

Using the UI, we can use the conditional based routing as well as attribute routing. Let's do the attribute routing. For that we need to use the route prefix attribute at the controller level. And specify that prefix API slash v1 slash employee and specify route for the our method that will be empty string when we are retrieving all of the employee. And when we are returning the employee with a given ID then we pass the ID within double quote. Let's try it.

Let's open the our API page that is slash API slash v1 slash less. employee. We can see that we are assuming the employer do worse than one. And let's specify the ID we are also able to recruit the editor or the employer with a given ID. Now our requirement is a change and along with the name we are going to pass the HR department name for the employee. For that we are going to create a version two which will be accessible from the changing the we do in the URL.

Now we are receiving the 404 error because we are not developed it that let's switch to Visual Studio. Stop the execution. I'm going to create a new model add a new class of meme employee version two which can then go to property. Along with this, it also contained the public shaming department name and also create a controller. Let's copy the existing one and change its name and change the route prefix to I have already a copy the list of the employee as per the employer words into a state instead of returning the employee offers on one we are going to return the words and two in both method and let's preview the our solution. Forget the semicolon.

Let's send request to the our version two. You can see that it's written the employee v2, and also contain the department name. And now we are going to retrieve the employee ID from the URL or the EPA and you can see that it does not return the department name. We are creating versioning of the our API on Ura based on the attribute routing, however, we can also provide versioning based on the conditional based routing. For this first of all, we need to stop the our solution and the comment in the comment do all of the attribute you know was in one Well, it's only to comment India wasn't too open the VBA config file. Copy the map attribute out tiara and comment is one, two Paste it change the anyone do a route, let us do was on one and it seems the routing template to the ones less.

Now we need to pass the controller name, controller equal to employee version one and I can copy and change your one to two. Let's build our solution. I'm going to reload the previous page you can see that the From the version one was received successfully, now we're going to chain to the version two. It was working same as the attribute routing, or attribute routing we need to use the route prefix or the route attribute at the controller or the action level. For conventional base routing, we need to modify the VPN config.cs file like that. 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.