- Ruby 2.4.1
- PostgreSQL
- Faker data
$ bundle install
$ rake db:create
$ rake db:migrate
$ rake db:seed
$ rails s
http://localhost:3000/api/vi/articles
choose content type and application/json in Headers
choose Body and type use json
{
"title": "Article from postman third",
"body": "Lorem Ipsum asas "
}
If success it will return like json format
{
"status": "SUCCESS",
"message": "Saved article",
"data": {
"id": 9,
"title": "Article from postman third",
"body": "Lorem Ipsum asas ",
"created_at": "2017-08-09T10:30:38.738Z",
"updated_at": "2017-08-09T10:30:38.738Z"
}
}
Methode GET
http://localhost:3000/api/v1/articles
and will return json format
{
"status": "hoho Sukses",
"message": "Loader article",
"data": [
{
"id": 7,
"title": "Article from postman",
"body": "Lorem Ipsum",
"created_at": "2017-08-09T10:29:50.978Z",
"updated_at": "2017-08-09T10:29:50.978Z"
},
{
"id": 6,
"title": "as",
"body": "as",
"created_at": "2017-08-09T10:29:06.283Z",
"updated_at": "2017-08-09T10:29:06.283Z"
},
{
"id": 5,
"title": "Butter In a Lordly Dish",
"body": "Accusantium ut modi quis amet.",
"created_at": "2017-08-09T08:03:07.171Z",
"updated_at": "2017-08-09T08:03:07.171Z"
},
{
"id": 4,
"title": "The Golden Apples of the Sun",
"body": "Occaecati architecto facilis expedita.",
"created_at": "2017-08-09T08:03:07.170Z",
"updated_at": "2017-08-09T08:03:07.170Z"
},
{
"id": 3,
"title": "As I Lay Dying",
"body": "Necessitatibus sed iusto quis mollitia aspernatur reprehenderit consequatur omnis.",
"created_at": "2017-08-09T08:03:07.168Z",
"updated_at": "2017-08-09T08:03:07.168Z"
},
{
"id": 2,
"title": "I Will Fear No Evil",
"body": "Voluptates laudantium facilis cumque rerum fuga iusto.",
"created_at": "2017-08-09T08:03:07.166Z",
"updated_at": "2017-08-09T08:03:07.166Z"
},
{
"id": 1,
"title": "The Road Less Traveled",
"body": "Rerum alias non pariatur perspiciatis quasi odit.",
"created_at": "2017-08-09T08:03:07.146Z",
"updated_at": "2017-08-09T08:03:07.146Z"
}
]
}
Methode GET
http://localhost:3000/api/v1/articles/article_id
example
http://localhost:3000/api/v1/articles/1
will return json format
{
"status": "hoho Sukses",
"message": "Loader article",
"data": {
"id": 1,
"title": "The Road Less Traveled",
"body": "Rerum alias non pariatur perspiciatis quasi odit.",
"created_at": "2017-08-09T08:03:07.146Z",
"updated_at": "2017-08-09T08:03:07.146Z"
}
}