Implement HTTP GET method

15 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
€48.27
List Price:  €67.58
You save:  €19.31
£40.07
List Price:  £56.10
You save:  £16.03
CA$71.86
List Price:  CA$100.61
You save:  CA$28.74
A$80.04
List Price:  A$112.06
You save:  A$32.02
S$68.31
List Price:  S$95.65
You save:  S$27.33
HK$388.64
List Price:  HK$544.12
You save:  HK$155.48
CHF 45.29
List Price:  CHF 63.41
You save:  CHF 18.12
NOK kr566.72
List Price:  NOK kr793.46
You save:  NOK kr226.73
DKK kr360.04
List Price:  DKK kr504.08
You save:  DKK kr144.04
NZ$88.69
List Price:  NZ$124.18
You save:  NZ$35.48
د.إ183.61
List Price:  د.إ257.07
You save:  د.إ73.45
৳6,064.90
List Price:  ৳8,491.34
You save:  ৳2,426.44
₹4,289.89
List Price:  ₹6,006.19
You save:  ₹1,716.30
RM225.50
List Price:  RM315.72
You save:  RM90.22
₦77,257.54
List Price:  ₦108,166.74
You save:  ₦30,909.20
₨13,902.64
List Price:  ₨19,464.81
You save:  ₨5,562.16
฿1,730.85
List Price:  ฿2,423.33
You save:  ฿692.48
₺1,766.88
List Price:  ₺2,473.77
You save:  ₺706.89
B$312.08
List Price:  B$436.94
You save:  B$124.85
R933.80
List Price:  R1,307.40
You save:  R373.59
Лв94.48
List Price:  Лв132.28
You save:  Лв37.80
₩73,223.92
List Price:  ₩102,519.35
You save:  ₩29,295.43
₪181.92
List Price:  ₪254.71
You save:  ₪72.78
₱2,911.11
List Price:  ₱4,075.79
You save:  ₱1,164.67
¥7,885.42
List Price:  ¥11,040.22
You save:  ¥3,154.80
MX$1,028.65
List Price:  MX$1,440.20
You save:  MX$411.54
QR181.98
List Price:  QR254.78
You save:  QR72.80
P693.81
List Price:  P971.38
You save:  P277.57
KSh6,461.20
List Price:  KSh9,046.20
You save:  KSh2,585
E£2,530.65
List Price:  E£3,543.12
You save:  E£1,012.46
ብር6,374.48
List Price:  ብር8,924.79
You save:  ብር2,550.30
Kz45,590.88
List Price:  Kz63,830.88
You save:  Kz18,240
CLP$50,160.15
List Price:  CLP$70,228.22
You save:  CLP$20,068.07
CN¥366.33
List Price:  CN¥512.90
You save:  CN¥146.56
RD$3,049.23
List Price:  RD$4,269.17
You save:  RD$1,219.93
DA6,789.98
List Price:  DA9,506.51
You save:  DA2,716.53
FJ$115.98
List Price:  FJ$162.39
You save:  FJ$46.40
Q385.14
List Price:  Q539.23
You save:  Q154.08
GY$10,438.94
List Price:  GY$14,615.36
You save:  GY$4,176.41
ISK kr6,956.10
List Price:  ISK kr9,739.10
You save:  ISK kr2,783
DH503.50
List Price:  DH704.94
You save:  DH201.44
L926.94
List Price:  L1,297.80
You save:  L370.85
ден2,970.88
List Price:  ден4,159.47
You save:  ден1,188.59
MOP$399.98
List Price:  MOP$560.01
You save:  MOP$160.02
N$936.90
List Price:  N$1,311.74
You save:  N$374.83
C$1,836.79
List Price:  C$2,571.65
You save:  C$734.86
रु6,853.79
List Price:  रु9,595.86
You save:  रु2,742.06
S/187.37
List Price:  S/262.33
You save:  S/74.96
K199.96
List Price:  K279.97
You save:  K80
SAR187.72
List Price:  SAR262.82
You save:  SAR75.10
ZK1,390.27
List Price:  ZK1,946.49
You save:  ZK556.22
L240.14
List Price:  L336.22
You save:  L96.07
Kč1,213.40
List Price:  Kč1,698.86
You save:  Kč485.45
Ft19,997.20
List Price:  Ft27,997.68
You save:  Ft8,000.48
SEK kr553.19
List Price:  SEK kr774.52
You save:  SEK kr221.32
ARS$51,615.42
List Price:  ARS$72,265.73
You save:  ARS$20,650.30
Bs344.95
List Price:  Bs482.97
You save:  Bs138.01
COP$217,506.97
List Price:  COP$304,527.16
You save:  COP$87,020.19
₡25,445.82
List Price:  ₡35,626.19
You save:  ₡10,180.36
L1,268.70
List Price:  L1,776.28
You save:  L507.58
₲390,771.79
List Price:  ₲547,111.78
You save:  ₲156,339.98
$U2,195.71
List Price:  $U3,074.18
You save:  $U878.46
zł205.80
List Price:  zł288.14
You save:  zł82.33
Already have an account? Log In

Transcript

Hello guys, welcome to quick session on the VBA tutorials Do you know we are trying to retrieve the data from the list. Now we are trying to retrieve the data from the database in your registration. For these we need to create the database already created a script which was available to you copy and open studio manager run it here is our table which contains the f5 field product ID name, quantity box size and the price I am already included here some dummy data for That return will be helpful to us. Switching to visit studio and creating the new project of the ASP. NET web application with the title GET request and select the VPI. Okay.

Here is our project folder trimming the data from the database. I'm going to use the Entity Framework for that. Do we need to do another Close it select here, class library, assign the name, product and do it. Okay. We does not need to class one.cs. So I'm going to right click and add new data and a do entity model and use the abroad model name.

We need to create the entity model from the database so select the first option and click on Next. Assembly z a new connection Write the server name. Select the database, click next and for success you can also change the name of your entity. Click on Next I'm going to use Entity Framework 6.0 and select a table that you want to use for the entity. Change the name for that model. Thankfully companies or entities created it creates all the property which are exiting the Our table we need to add the reference should that project in the our API project, select the project and select the entity.

Okay. Now we need to add the new controller. Right click on the controller folder, select the controller. I'm going to use the empty controller. controller name would be a product controller. First of all we need to add the our entity namespace that is a product entity.

Then we need to create the metaphor, crushing data. We are going to create the toolkit My third one will fit in the ienumerable of the prototype and the another return the instance of the product. First of all we will refer to the all of the data. For that I'm going to write the public I enumerable of product of my time which does not require the any parameters using corporate entities at the core to know can TV Return door products door to list the product class was not created by us it was created by the product entity itself. If I click and go to definition here is its definition which contain the product ID name, quantity, book size and the price which was exist in the our product table. And we were reviewing the all of the products from the entity as written as the least.

Now going to build your solution Opening the API is less controller name that is the product who can see that it will generate the exception. No connection string name product entity could be pounding The our application configuration file. For that, we need to open the app dot config file of the our entity project and copy that connection string straight into the dot config. next section we need to rebuild our solution and reload that page. You can see that it returned the adoptee a product, which can then be a multiple product elements which are accessing the database with the all of the items including the product ID, quantity, price, name, and more. says those are sorted by the name.

So box Id come the flesh instead of the product ID. Those all properties are sorted. That's why the book says first instead of the product ID going to write to get metadata shoot a specific item which will return the product and take the ID as a parameter. Again we need to use the using statement. corporate entities, entity or equal to new product entity Create the instance up here product name and put your form and today's product. First of all before x, such that dot product ID equal equality, IQ and Id we need to return the product insurance can be the solution.

I'm going to open the postman plugin Copy the URL, state and write the API slash Florida which will return all of your products. And now we're going to write here assuming the product of ID three, which is a pain and you can see that it returned the pain. But what happened when we are using the ID which does not really exist? In that case, it is returning DNA with the status code 200 that is okay. But in the IRS full services we need to return the 404 not found status code. So we need to modify it open the original studio.

For that instead of returning the product instance we need to return the TTP response message. And we need to check that if product is no then we need to return the request nor create a response for that with the database status code. Model phone that is for To sit and do a message that is product with you on ID does not exist otherwise we need to return request dot create response with the status code, okay and as to order object itself and click on the period resend the request. Here is we are receiving the message product with Diego and it does not exist at 404 more phone status. Now trying to send the request for the ID which exist. That's it.

It's written in the order detail with the status code 200. In this reality in this lesson we are learn about the HTTP response message. A TTP response method is a way to returning the message or the data from the our action that is a method. request or create response or request dot create error response metadata used to create the UDP response message is the two parameter. Firstly is HTTP status code which will set the status code for the our ITP response and the type T. It is the object that we are really want to return. Here is a core for returning the all of the element from the entity.

Can here is a code for returning the data for the specific ID. Thanks for watching.

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.