0

I would like to upload a file to my Github repo from Postman. What I have tried is:

  1. Generate token from PAT: https://github.com/settings/tokens.
  2. Method PUT URL: https://github.com/username/test2/info/lfs/objects/cd00e292c5970d3c5e2f0ffa5171e555bc46bfc4faddfb4a418b6840b86e79a2
  3. Body is a 1 MB file.

I am receiving the following error: Your browser did something unexpected. Please contact us if the problem persists.

Raj
  • 165
  • 3
  • 15

1 Answers1

2

According to the API Reference you can't simply PUT a file to that URL. Rather, you need to encode the file as Base64, and put it within a JSON object with the following inputs:

{
  "message": "my commit message",
  "committer": {
    "name": "Scott Chacon",
    "email": "schacon@gmail.com"
  },
  "content": "bXkgbmV3IGZpbGUgY29udGVudHM="
}
Derek Brown
  • 4,232
  • 4
  • 27
  • 44
  • 1
    @ParinSanghavi take a look at this- https://stackoverflow.com/questions/201479/what-is-base-64-encoding-used-for – Derek Brown Oct 20 '17 at 16:59
  • Can you explain the entire process with steps? I should probably learn about REST sometime. – Raj Oct 20 '17 at 17:01
  • @ParinSanghavi you mean of encoding in Base64? Or uploading a file to github? – Derek Brown Oct 20 '17 at 17:02
  • 1
    @ParinSanghavi you will need to read the data in from a datafile (https://www.getpostman.com/docs/postman/collection_runs/working_with_data_files), use Javascript to base64 encode it, and then `PUT` it using the JSON format I described above. – Derek Brown Oct 20 '17 at 17:13