Oynatıcıya atla
Ana içeriğe atla
Altbilgiye atla
Ara
Oturum açın
Tam ekran izle
Beğen
Yorumlar
Yer işareti ekle
Paylaş
Çalma Listesine ekle
Bildir
31 - Test API Functions
Mustafa Demirhan
Takip Et
24.08.2024
Kategori
📚
Öğrenme
Döküm
Tüm video dökümünü görüntüle
00:00
Let's get back on it and let us test this out.
00:04
I'm just going to run without debugging,
00:06
so that it loads a bit more quickly,
00:09
and we're just going to use Swagger tool to test this API.
00:13
Now, an alternative to Swagger would have been
00:16
like Postman or something similar to that,
00:19
but Swagger is capable,
00:21
so we'll just use it right now.
00:23
When we expand our get,
00:26
that implies that we'll be getting back a collection.
00:30
We'll see the sample object of what we'll be getting back,
00:34
and notice the square braces that depicts
00:37
that it will be an array, right, of objects.
00:41
Let us try it out and execute,
00:44
at which point it actually goes and queries the database,
00:47
and there are all of the sample cars
00:51
that we would have entered, right?
00:54
Now, if I try to get by ID, let me try that one.
00:59
So try it out, it says, give me the ID, I'll give it 10,
01:02
and we get back the 200 response with the car with the ID 10.
01:08
If I try it with 100, I don't have 100 cars,
01:11
so this time I get back that 404,
01:13
because it couldn't find that car by that ID, right?
01:17
And you can pay attention to the response URLs,
01:20
namely, this is what you call the base URL,
01:24
because that's a server,
01:25
and then this will be the path,
01:26
and then that will be our ID value going over, right?
01:31
So it's good to pay attention to these little things,
01:33
because when we're writing code to interact with the API,
01:36
we have to mimic these kinds of URLs.
01:40
So that verifies that our get by ID works.
01:44
Let's try the put.
01:45
So if I try to modify car with ID one,
01:50
and let's say I make it into string, string,
01:54
so let me first retrieve the car with the ID one,
01:56
so we can see what it looked like.
01:59
So that is the car with the ID one.
02:01
Let me take a quick copy of it.
02:03
It's a Honda Fit Vinny's ABC.
02:06
Now, when I run this,
02:09
I notice I would have to put in all the details
02:12
I intend to update with.
02:13
So if I leave the defaults and click execute,
02:16
it's going to tell me no content,
02:18
which means it was successful.
02:20
If I attempt to retrieve this car again,
02:23
then I'm going to see that it is not working.
02:30
Let's set the code.
02:33
And, oh, my bad.
02:36
Oh, this is my silly mistake.
02:38
So I actually mixed up the assignments.
02:41
So I should have been assigning record,
02:45
the values coming in through car.
02:47
So I apologize for that.
02:49
Mix up, and I have on my hot reload on save.
02:52
So I should be able to just go back and try again.
02:56
So let's execute.
02:57
We're seeing one Honda Fit and everything.
03:01
And then when I try to execute here,
03:05
I get the 204.
03:08
So now I'm seeing, there we go.
03:12
So now we're seeing everything change the string.
03:16
My silly mistake, guys.
03:17
So that works.
03:19
And that's why testing is important, right?
03:22
So let me just revert to my original payload
03:26
and then execute again.
03:29
And then we can verify that we now see the original data.
03:33
Right, looking good.
03:35
And then the final one is the delete.
03:39
So which one would I want to delete?
03:40
Let us delete, I'm not,
03:45
I don't want to say what kind of car I'm not fond of,
03:48
but I'm going to delete the one that I'm least fond of
03:52
in this list.
03:54
And that would be the car with the ID four.
03:59
A bit too small for my taste.
04:01
So there we get the 204 that suggests
04:04
that it was completed successfully.
04:06
So if I go back and execute,
04:08
there is no longer a car with the ID four.
04:11
And just like that, our CRUD works.
Önerilen
14:04
|
Sıradaki
30 - Configure API Endpoints
Mustafa Demirhan
24.07.2024
20:07
35 - Refactor MAUI App for API
Mustafa Demirhan
24.08.2024
8:53
39 - Add Identity to API
Mustafa Demirhan
24.08.2024
14:11
33 - Refactor and Publish API To Local Server
Mustafa Demirhan
24.08.2024
17:56
44 - Authentication and Authorization to API
Mustafa Demirhan
02.09.2024
14:00
36 - Essential Fixes
Mustafa Demirhan
24.08.2024
1:08
32 - Prepare Server for API Deployment
Mustafa Demirhan
24.08.2024
1:21
37 - Section Summary
Mustafa Demirhan
24.08.2024
20:55
21 - Implement a Details Page
Mustafa Demirhan
24.07.2024
7:50
34 - Configure Mobile App for Network Connections
Mustafa Demirhan
24.08.2024
5:16
48 - Handle Logout
Mustafa Demirhan
02.09.2024
23:05
47 - Adjust App Flow and Layout
Mustafa Demirhan
02.09.2024
6:41
26 - Section Overview
Mustafa Demirhan
24.07.2024
2:16
49 - Section Summary
Mustafa Demirhan
02.09.2024
6:59
18 - Understanding Dependency Injection
Mustafa Demirhan
18.07.2024
6:51
25 - Section Summary
Mustafa Demirhan
24.07.2024
14:28
19 - Implement Data Template and Collection View
Mustafa Demirhan
18.07.2024
6:36
43 - Seed Users and Roles
Mustafa Demirhan
02.09.2024
3:46
14 - Create Data Access Services
Mustafa Demirhan
18.07.2024
0:56
11 - Section Overview
Mustafa Demirhan
18.07.2024
4:46
13 - Create Data Model
Mustafa Demirhan
18.07.2024
15:35
42 - Add App Login Page
Mustafa Demirhan
02.09.2024
1:32
01 - Introduction
Mustafa Demirhan
15.07.2024
16:25
02 - Setup Development Environment
Mustafa Demirhan
15.07.2024
2:39
28 - Setup CORS Policy
Mustafa Demirhan
24.07.2024