Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle API -> Create a new Calendar -> Parse Error
    primarykey
    data
    text
    <p>I'm trying to create a Calendar through the Google API as per the <a href="https://developers.google.com/google-apps/calendar/v3/reference/calendars/insert" rel="nofollow">documentation</a>. I am trying to avoid using the Client libraries and do all communication with the API through custom webrequests and so far that has been working nicely but on this particular one I'm struggling with a <em>"parse error"</em>.</p> <p>Please do not refer to solutions that use the client libraries (<em>service.calendars().insert(...)</em>).</p> <p>This is a dumbed down version of my code (still not working):</p> <pre class="lang-cs prettyprint-override"><code>var url = string.Format ( "https://www.googleapis.com/calendar/v3/calendars?key={0}", application.Key ); var httpWebRequest = HttpWebRequest.Create(url) as HttpWebRequest; httpWebRequest.Headers["Authorization"] = string.Format("Bearer {0}", user.AccessToken.Token); httpWebRequest.Method = "POST"; httpWebRequest.ContentType = "application/json"; httpWebRequest.CookieContainer = new CookieContainer(); // Obviously the real code will serialize an object in our system. // I'm using a dummy request for now, // just to make sure that the problem is not the serialization. var requestText = "{" + Environment.NewLine + "\"summary\": \"test123\"" + Environment.NewLine + "}" + Environment.NewLine ; using (var stream = httpWebRequest.GetRequestStream()) using (var streamWriter = new System.IO.StreamWriter(stream)) { streamWriter.Write(System.Text.Encoding.UTF8.GetBytes(requestText)); } // GetSafeResponse() is just an extension that catches the WebException (if any) // and returns the WebException.Response instead of crashing the program. var httpWebResponse = httpWebRequest.GetSafeResponse(); </code></pre> <p>As you can see, I've given up on sending serialized objects for now and I'm just trying to get it working with a very simple dummy request:</p> <pre><code>{ "summary": "test123" } </code></pre> <p>Yet the response is still just:</p> <pre><code>{ "error": { "errors": [ { "domain": "global", "reason": "parseError", "message": "Parse Error" } ], "code": 400, "message": "Parse Error" } } </code></pre> <p>The accessToken is valid and not expired, the application key is correct.</p> <p>What am I doing wrong or missing?</p> <p>Thanks in advance,</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload