99 search results

Logout & Passing API Data to JavaScript

…that endpoint... which would either return null or the current user info. But, /me endpoints are super not RESTful. And there's a better way: dump the user information into JavaScript on page load. There are two different ways to do this. The first is…

5:45
On Authentication Success

…id. But we could, if we wanted, return the entire user object as JSON. But there's one tiny problem with that. It's not super RESTful. This is one of those "REST purity" things. Every URL in your API, on a technical level, represents…

6:03
JSON-LD: Context for your Data

…all starting with @ - that help machines learn more about your API. So, first: @id. In a RESTful API, every URL represents a resource and should have its own unique identifier. JSON-LD makes this official by saying that every resource should have an @id field…

10:30
API Auth 101: Session? Cookies? Tokens?

…How does it respond when you successfully authenticate? And you might be thinking: Hey! We're building a RESTful API... and APIs are supposed to be "stateless"... so that means don't use sessions... and so that means our API will return some sort of…

4:05
Logout & Passing API Data to JS on Page Load

…A useful, but not-so-RESTful endpoint. The other option is quite nice: send the user data from your HTML into Vue on page load. Open up the template for this page: templates/frontend/homepage.html.twig. Yep, nothing here but some small HTML to…

8:49
Transitions and Client State

…the APIs that you’re used to. We won’t talk about it initially, but a big part of building a RESTful API is sending back links along with your data. These tell you the most likely URLs you’ll want your API to follow…

2:11
Publishing a Listing

…or "operation" in ApiPlatform language. Something like POST /api/cheeses/{id}/publish. You can do this. And we'll talk about custom operations in part 4 of this series. But this solution would not be RESTful. In REST, every URL represents the address to a…

6:02
App & Test Setup

…when that happens... kind of like a custom "publish" operation... but with a RESTful twist. We'll also add complex security rules around who can publish an item under different conditions. Then we'll do everything custom: add completely custom fields, completely custom API resources…

7:44
Production Settings with SendGrid

…it's called a "Password". In reality, this is a SendGrid API key - you could use it to send emails through their RESTful API. But because SMTP authentication works via a username and password, SendGrid tells us to use apikey as the username and this…

6:51
JSON up in your Response

…attend still works too. So if the format part is missing, the route still matches. In a truly RESTful API, it’s more “correct” to read the Accept header instead of putting the format in the URL like we’re doing here. If you’re…

2:50
Contentful: Loading Data from an External CMS

…bunch of data. So, you create and maintain your content here. Then Contentful has a restful API that we can use to fetch all of this. Contentful is cool. But the point of this isn't to teach you about Contentful. Nope! It's to…

8:02
Reordering Endpoint & AJAX

…reorder_references. If you're wondering about the URL or the method POST, well, this endpoint isn't very RESTful.. it doesn't fit into the nice create-read-update-delete model... and that's ok. Usually when I have a weird endpoint like this…

7:41
Edit Endpoint & Deserialization

…Let's do it! Let's keep thinking about our ArticleReference routes as a set of nice, RESTful API endpoints. We already have an endpoint to create and delete an ArticleReference. This will be an endpoint to edit a reference... except that the only field…

5:07
POST: Creation, Location Header and 201

…we don’t have an endpoint to get a single programmer representation yet. To avoid angering the RESTful elders, let’s add a location header, and just fake the URL for now: // src/KnpU/CodeBattle/Controller/Api/ProgrammerController.php // ... public function newAction(Request $request) { } If…

4:53
UUID Quirk with "id" Name

…code on a "state change", like when a cheese listing becomes published. That's a great way to keep your endpoints RESTful, but still run the business code you need in situations like this. In the next course, we'll dive a bit deeper into…

7:09
Publish State Change Validator Logic

…but... sweet! We can see the response: a giant 403 error. I'll comment that out and keep my validation logic: We now have a RESTful way to publish a listing and execute custom logic! In the fourth part of this series, we'll talk…

8:26
Detecting the "Published" State Change

… It passes! Woo! This "original data" trick is really the key to doing custom things on a simple, RESTful state change, like isPublished going from false to true. Next: let's use this same trick to accomplish something else. Let's add complex rules around…

9:08
PATCH: The Other Edit

…have 2 methods a client can use to update a resource: PUT and PATCH. Should I Support PUT and PATCH?¶ All of this wouldn’t be RESTful if it weren’t a bit controversial. Because PUT’s correct behavior is harsh, many APIs support PUT…

4:53
If the project involves developing a RESTful API and we plan to make requests to our own API, it would be ideal to have functional tests with fake fixtures, or having unit tests (using mocks), or both types of tests.
Hi there, It works well in RESTFul api. I'd like to know if there is a way to handle adding and removing element from ManyToMany collection using Graphql? I tried to use updateResource but it seems that the property always got overridden. Thanks.
Tianyu W.
Tianyu W.
Read Full Comment