ruby - Github API responding with 'Content is not valid Base64' -


i getting 'content not valid base64' error when posting certain, simple, piece of content github using api. content

 unit = $("<li  class='s   clearfix'></li>"); 

i using base64.urlsafe_encode64 encode content.

content = 'unit = $("<li  class=\'s   clearfix\'></li>")'; url = "https://api.github.com/repos/#{github_user}/#{github_repo}/contents/#{path}" restclient.put(url,                     {                        message: "my message",                        content: base64.urlsafe_encode64(content),                        encoding:"base64" }.to_json,                    {                        params:{access_token:access_token                    },accept:'json'}){ |response, request, result|     puts response.code    puts response } 

i getting reponse:

422 {"message":"content not valid base64",  "documentation_url":"https://developer.github.com/v3/repos/contents/"} 

i don't understand how cannot valid base64 github. , doesn't happen submitted data.

content='unit = $("<li  class=\'s   clearfix\'></li>")' base64.urlsafe_decode64(base64.urlsafe_encode64(content))==content => true 

what doing wrong?

turns out content has encoded base64.strict_encode complies rfc 4648. found solution here on github: https://github.com/octokit/octokit.rb/blob/5323df945ecfd524556888e35d042a96c9055a1c/lib/octokit/client/contents.rb#l76


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -