포스트맨으로 Git Repository 파일 수정하기
참고자료
https://stackoverflow.com/questions/48745796/github-api-v3-update-file-not-working-404
Github API v3: Update file not working (404)
I'm trying to update a file using the Github v3 api. Most of the documentation I could find was based on the older API. I want to utilize: https://developer.github.com/v3/repos/contents/#update-a-f...
stackoverflow.com
https://stackoverflow.com/questions/20207594/how-to-find-a-github-file-s-sha-blob
How to find a Github file 's SHA blob
I'm using this API to update a file on my repo, it requires me to have a valid SHA blob for a file that I want to update: http://developer.github.com/v3/repos/contents/ How do I find the SHA blob...
stackoverflow.com
깃허브 API 메뉴얼 : https://developer.github.com/v3/repos/contents/#update-a-file
Contents
Get started with one of our guides, or jump straight into the API documentation.
developer.github.com
1 API ENDPOINT
위 메뉴얼에 설명이 되있긴하지만 메뉴얼만으로는 무슨말인지ㅠ 구체적으로 어떻게 해야할지 모르겠음.
그래서 조사결과
깃 레파지토리 파일을 수정하기 위한 엔드포인트 :
https://api.github.com/repos/유저이름/레파지토리이름/contents/파일이름
회색 글씨는 그대로 쓰면되고 파란글씨에는 맞는 값을 넣으면된다.
보내는 방식은 PUT로 한다
2 쓰기권한 있는 OAuth 인증키 생성
일단 Headers에 인증키를 넣어야하는데 깃허브 계정페이지에서 얻을 수 있다.

프로필 사진을 눌러서 Settings > Developer settings > Personal access tokens 메뉴를 클릭한다.

이미 기본토큰들이 있겠지만 새로운 토큰을 만들어야한다. 쓰기 권한있는 토큰이 필요하기 때문.

필요한 권한들을 클릭해주고 생성된 키 값을 복사한다.
3 Headers 작성
그리고 Headers에 다음과 같이 Key는 Authorization으로 value는 token이라 쓰고 한칸 띄우고 복사한 토큰값을 붙여넣는다.

4 Body 작성
바디에는 다음과 같이 JSON형식으로 보낸다.
message, content, sha값은 필수값이므로 누락되면 에러메세지를 리턴한다.
message는 커밋 메세지를 쓰면되고 content는 Base64 형식으로 인코딩된 값을 넣어야한다.
4-1 content 값 작성
Base64 Encode and Decode - Online
Decode from Base64 or Encode to Base64 - Here, with our simple online tool.
www.base64encode.org
위 링크에서 변환하여 붙여넣으면 된다.
4-2 sha값 알아내기
sha값은 지금 PUT할 url을 GET방식으로 요청하면 리턴되는 json에 sha값이 있다.
일단 GET방식으로 던져서 sha값을 복사하여 PUT으로 던질 양식을 완성한다.

5 수정요청 보내기
드디어 Headers와 Body가 올바르게 완성되었으므로 Send를 클릭하면
성공리턴 제이슨이 온다.
그리고 주의할 점은 content 값으로 내용이 완전 대체 된다는 점이다.
content 값으로 기존 파일에 추가가 아니라 덮어쓰기된다.
