How to use github api from postman

Viewed 3463

i want to create a file on my github account using github api through postman.

github api to create a file on github account:

PUT /repos/:owner/:repo/contents/:path 

can anyone tel me how to use this api in postman.

i have my public github account : https://github.com/ritzygithub/myfirstRepo

and in postman header i set

Authorization type to OAuth 2
Authorization : token <token>
PUT request with url: https://api.github.com/repos/ritzygithub/myfirstRepo/

enter image description here

Can you please help me out in this

1 Answers

i just figured it out.. posting my answer here so that if anyone is facing same issue then this can help them.

In postman, set as PUT request with below URL

https://api.github.com/repos/YourUsername/YourRepo/contents/file.txt

Add Body:

{
  "message": "my commit message",
  "committer": {
    "name": "My name",
    "email": "my email"
  },
  "content": "base64encoded"
}

Header: Content-Type : application/json Authorization : token

Refer below Screenshot: enter image description here

Hope this helps. Thanks

Related