title: Base64 decode json array sent from URL
body: <p>I want to decode a simple json array using C# that's stored in a GitHub repo to see if it contains a value.  I'm using the Newtonsoft json package.  I've read this thread: <a href="https://stackoverflow.com/questions/1228701/code-for-decoding-encoding-a-modified-base64-url">Code for decoding/encoding a modified base64 URL</a>, but I can't seem to implement the solution.  I get the following error: </p>
  
  <blockquote>
    <p><strong>System.FormatException</strong>: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters,
    or an illegal character among the padding characters</p>
  </blockquote>
  
  <p>, but I think there's also something going on with the code.</p>
  
  <pre><code>var value = "somestring";
  var encodedTopicTypeURL ="https://api.github.com/repos/org/repo1/contents/sample.json";
  string decodedTopicTypeURL;
  byte[] buffer = Convert.FromBase64String(encodedTopicTypeURL);
  decodedTopicTypeURL = Encoding.UTF8.GetString(buffer);
  
  using (var webClient = new System.Net.WebClient())
  {
      var topicTypeJson = webClient.DownloadString(decodedTopicTypeURL);
      JArray validTopicTypes = JArray.Parse(topicTypeJson);
      if (!validTopicTypes.Contains(value))
      {
          Logger.LogError($"Value not found");
       }
  </code></pre>
  
  <p>Json array:</p>
  
  <pre><code>[
  "string1",
  "string2",
  "string3",
  "string4",              
  ]
  </code></pre>