title: github api "message":"Problems parsing JSON" for large Base64 string
body: <p>I'm trying to learn to use the guthub api from Java.
  I've created a simple program that can read and commit new versions of a file.
  I have tested this for many text files of short lenght and I think I'm correctly using the mime base64.
  I'm now trying to upload a larger file, in the order of 5 MB.
  And this means having a JSON in the body looking like this:</p>
  <pre><code>{
  &quot;owner&quot;: &quot;example42gdrive&quot;,
  &quot;repo&quot;: &quot;Example1&quot;,
  &quot;message&quot;: &quot;FileSystem 42 module on github&quot;,
  &quot;content&quot;: &quot;rO0ABXNyABdpcy5MNDIuZ2V ...5MB of JS string here... ABGluZm90AB5MfqIDcQB+AAU=&quot;,
  &quot;sha&quot;:&quot;a7ef93d3eb50383028578cb916b70060067d9c8a&quot;
  }
  </code></pre>
  <p>And I get back as a response</p>
  <pre><code>400
  {&quot;message&quot;:&quot;Problems parsing JSON&quot;,&quot;documentation_url&quot;:&quot;https://docs.github.com/rest/reference/repos#create-or-update-file-contents&quot;}
  </code></pre>
  <p>Notes:</p>
  <ul>
  <li><p>The same exact code works for smaller content</p>
  </li>
  <li><p>java Base64.getMimeEncoder() will insert some \n in the result to separate it in lines. I'm removing those newlines in order to get a valid JS string.</p>
  </li>
  </ul>
  <p>Does anyone knows what I'm doing wrong or what should I do instead?</p>
  <p>EDIT: after some experimentation, the problem seams to be in the \n:
  if I produce a base64 string short enough that java Base64.getMimeEncoder() does not insert any \n, all is fine. Of course, a string with a \n can not be 'stringyfied'  by simply adding (&quot;) before and after, so I tried</p>
  <ul>
  <li>removing the \n, no effect -&gt; Problems parsing JSON</li>
  <li>replacing the \n with \n (so that the parser will see them as \n inside a string) -&gt; Problems parsing JSON</li>
  <li>replacing the \n with \\n (so that the parser will see them as \n, this may help if there are somehow two levels of escape server side -&gt;Problems parsing JSON</li>
  <li>replacing the \n with a space -&gt;Problems parsing JSON</li>
  </ul>
  <p>In  <a href="https://en.wikipedia.org/wiki/Base64" rel="nofollow noreferrer">https://en.wikipedia.org/wiki/Base64</a>
  wikipedia clearly states that</p>
  <pre><code>(newlines and white spaces may be present anywhere but are to be ignored
   on decoding)
  </code></pre>
  <p>I'm starting to think that there is something I do not understand and that is so obvious that the github api do not mention it</p>