# #130 API CRUD endpoints

- URL: https://superails.com/posts/rails-7-130-api-crud-endpoints
- Published: 2023-05-08
- Duration: 20:10
- Access: free
- Topics: rest api, api development, rails api
- Playlists: Rails REST API

Create an API Controller where you can LIST, SHOW, CREATE, UPDATE, DESTROY records.

Episode source code: https://github.com/corsego/130-api-crud-endpoints/commit/de101248398714ec367cf3c4dfad7e95c8373d4f
Based on this blogpost: https://blog.corsego.com/rails-api-bearer-authentication

0:00 Recap of what we already have
2:00 scaffold Posts, belong to user
3:45 WTF Format JSON
5:05 WTF JBUILDER
6:08 cURL request to access posts
7:07 Access Posts controller within our API
11:42 API controller authorization - user can access only his own posts
13:30 fix ActiveRecord::RecordNotFound error
14:59 CREATE via API, fix InvalidAuthenticityToken
16:40 UPDATE via API. Importance of strong params
18:17 DESTROY via API
19:20 cleanup API controller
19:36 summary

## Chapters

- 0:00 Recap of what we already have
- 2:00 scaffold Posts, belong to user
- 3:45 WTF Format JSON
- 5:05 WTF JBUILDER
- 6:08 cURL request to access posts
- 7:07 Access Posts controller within our API
- 11:42 API controller authorization - user can access only his own posts
- 13:30 fix ActiveRecord::RecordNotFound error
- 14:59 CREATE via API, fix InvalidAuthenticityToken
- 16:40 UPDATE via API. Importance of strong params
- 18:17 DESTROY via API
- 19:20 cleanup API controller
- 19:36 summary
