hyz901214 / r-google-analytics

Automatically exported from code.google.com/p/r-google-analytics
0 stars 0 forks source link

Internal Error,Error code 500 #20

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Inserting activity using web request to api 
https://www.googleapis.com/youtube/v3/activities

What version of the product are you using? On what operating system?
youtube api version v3 
operating  system windows 7

Please provide any additional information below.
My code is:
string URL = 
"https://www.googleapis.com/youtube/v3/activities?part=snippet&key=apikey";
string DATA = @"{'snippet': {'description': 'reply via api','channelId': 
'youtube channelid'}}";
byte[] byteArray = Encoding.UTF8.GetBytes(DATA);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
request.Method = "POST";
request.UserAgent = "Google APIs Explorer";
request.ContentType = "text/json; charset=utf-8";
request.ContentLength = byteArray.Length;
request.Headers[HttpRequestHeader.Authorization] = "Bearer access token";

using (Stream dataStream = request.GetRequestStream())
{
   dataStream.Write(byteArray, 0, byteArray.Length);
}

WebResponse webResponse = request.GetResponse();
using (Stream webStream = webResponse.GetResponseStream())
{
   if (webStream != null)
   {
      using (StreamReader responseReader = new StreamReader(webStream))
      {
          string response = responseReader.ReadToEnd();
          Console.Out.WriteLine(response);
       }
    }
}

Original issue reported on code.google.com by sudhir.k...@gmail.com on 12 Feb 2014 at 12:28