Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curlでAPI操作例 #2

Open
Fendo181 opened this issue Feb 13, 2018 · 0 comments
Open

curlでAPI操作例 #2

Fendo181 opened this issue Feb 13, 2018 · 0 comments

Comments

@Fendo181
Copy link
Owner

Get all authors.

  • method:GET
curl http://localhost:8080/api/authors | jq

result

[
  {
    "id": 1,
    "name": "",
    "email": "",
    "github": "",
    "twitter": "",
    "location": "",
    "latest_article_published": "",
    "created_at": "2018-02-13 10:12:58",
    "updated_at": "2018-02-13 10:12:58"
  },
  {
    "id": 2,
    "name": "",
    "email": "",
    "github": "",
    "twitter": "",
    "location": "",
    "latest_article_published": "",
    "created_at": "2018-02-13 10:13:54",
    "updated_at": "2018-02-13 10:13:54"
  },
  {
    "id": 3,
    "name": "endo",
    "email": "email@email.com",
    "github": "Fendo181",
    "twitter": "Fendo181",
    "location": "chiba",
    "latest_article_published": "2018/2/10",
    "created_at": "2018-02-13 10:19:48",
    "updated_at": "2018-02-13 10:19:48"
  }
]

Get one author.

  • method:GET
curl http://localhost:8080/api/authors/3 | jq

result

{
  "id": 3,
  "name": "endo",
  "email": "email@email.com",
  "github": "Fendo181",
  "twitter": "Fendo181",
  "location": "chiba",
  "latest_article_published": "2018/2/10",
  "created_at": "2018-02-13 10:19:48",
  "updated_at": "2018-02-13 10:19:48"
}

Add a new author.

  • method:POST
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"name":"endo", "email":"email@email.com", "github":"Fendo181","twitter":"Fendo181", "location":"chiba", "latest_article_published":"2018/2/10"}  http://localhost:8080/api/authors

Edit an author

  • method:PUT
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X PUT -d '{"name":"ENDO", "email":"email@email.com", "github":"Fendo181","twitter":"Fendo181", "location":"chiba", "latest_article_published":"2018/2/10"}' http://localhost:8080/api/authors/3

Delete an author.

  • method:DELETE
curl -X DELETE http://localhost:8080/api/authors/1
@Fendo181 Fendo181 changed the title curiでAPI操作例 curi でAPI操作例 Feb 13, 2018
@Fendo181 Fendo181 changed the title curi でAPI操作例 curlでAPI操作例 Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant