The POST Create API
We now GET and DELETE the rep logs via the API. The last task is to create
them when the form submits. Look back at RepLogController: we can POST
to /reps to create a new rep log. I want to show you just a little…
Logout & Passing API Data to JS on Page Load
…see
that we're currently logged in. And now... gone! We are anonymous.
Before we keep going with all this API & security goodness, our app has a bug.
If we log in... as soon as the AJAX call finishes, we've made our Vue.js…
JSON Errors in your API
Whenever something goes wrong in our API, we have a great setup: we always get
back a descriptive JSON structure with keys that describe what went wrong:
I want to do the exact same thing when something goes wrong with authentication.
Open up the TokenControllerTest…
A Homepage for your API?
…again!
Now, we need the name of the route. So let's go give this new route a name:
api_homepage:
We'll use this in the Relation. And because there aren't
any wildcards in the route, we don't need any parameters.
Cool…
Coding the API Upload Endpoint
…back
down to setOriginalFilename() and paste! And if for some reason it's not set,
we can still use $filename as a backup. But that's definitely impossible for our
API-style thanks to the validation rules.
Deep breath. Let's try it again. Woh…
POSTing to the API Endpoint
Before we keep going, I want to go back and look at what it used to look like
when we submitted the form. I have not refreshed yet, and this AJAX call is an
example of what the POST request looked like using our old…
Proper JSON API Endpoint Setup
…you,
awesome, use Symfony forms.
We need to make two adjustments. First, get rid of the CSRF _token field. Protecting
your API against CSRF attacks is a little more complicated, and a topic for another
time. Second, when you use the Symfony form component, it…
Symfony RESTful API: Hypermedia, Links & Bonuses (Course 5)
…These can make your API awesome, or could bring
you to your knees with fuzzy details, missing best practices and complexity.
Let's make our API awesome:
Linking to Resources (and Hypermedia) without hating it
Controlling your JSON fields with VirtualProperty and SerializedName
Customizing your…
Symfony RESTful API: Authentication with JWT (Course 4)
After 3 tutorials, we've got a nice API, But we've been completely ignoring
authentication. What about API tokens? Or properly handling errors? Thanks to some modern tools, this will be such a treat:
Understanding JSON web tokens (JWT)
Creating, signing & returning JWT's…
Symfony RESTful API: Basics++ (Course 3)
…
Errors, double check!
Now let's get back to some core API concepts and take things up a level by covering a bunch of features that you need... but sometimes can't find related to REST!
REST Pagination
Including next/prev pagination links
Filtering collections…
Symfony RESTful API: Errors (Course 2)
…which
is why we're covering this in episode 2.
So, let's handle errors, and let's do it gracefully:
Handling Form Validation errors and response
Disabling csrf_protection
Introducing the api-problem JSON format
Exception Listener!
Consistent errors everywhere: 404's, 500's…
Symfony RESTful API: Course 1
…same API in the
REST series, but leveraging
all the amazing tools and libraries of the Symfony framework. If terminology
like representations, resources, and hypermedia are new to you, start
with the REST series and
then come back. And get ready to get your (API…
The Twig Service & Profiler for API Requests
…seeing all the log messages
that were made only during that last request to the homepage.
Great! Except that... our log message is made on an API endpoint... and API
endpoints don't have a web debug toolbar we can click! Are we stuck? Nope…
Symfony Serializer - nasz przyjaciel w pracy z API (Paweł Skotnicki)
Jako programiści aplikacji internetowych często stykamy się z różnymi API - jako dostawcy i konsumenci - a to oznacza konieczność serializacji i deserializacji.
To bardzo szerokie zagadnienie, ale Symfony dostarcza nam komponent, który pomoże nam rozwiązać większość problemów z którymi się spotkamy.
W prezentacji przedstawię użycie komponentu…
Creating Token Resources in the API
…like a programmer
resource. So the scenario for this is going to look really similar. The only
difference is that we can’t authenticate with an API token, because that’s
what we are trying to get. So instead we’re going to authenticate with…
`api_platform:
resource: .
type: api_platform
prefix: /api
`
in api_plataform.yaml not work for me , I have to put in route.yaml of config
API Platform first please! :)
Strange Api-platform activity. It looks like ApiProperty Attribute doesn't work with json format. Why? And how to make ApiProperty to work on json format too?
I have simple ApiResource example
```
#[ApiResource()]
class UserApi
{
public ?int $id = null;
public ?string $firstName = null…
Historically API Platform would essentially treat PUT operations as PATCH operations and be used for partially updating resources. I believe in latest versions of API Platform the PUT operation now actually acts like a true PUT, where where all non-specified fields are removed (set…
x
1000+