Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ContactsRequest.Insert() fails with System.Net.ProtocolViolationException #692

Open
GoogleCodeExporter opened this issue Feb 25, 2016 · 0 comments

Comments

@GoogleCodeExporter
Copy link

I followed this documentation on the contacts api 
https://developers.google.com/google-apps/contacts/v3/#creating_contacts for 
creating a new contact.

Create a new Contact and populate with data like phone, email etc.

    var newEntry = new Contact();

Construct a new uri and issue an Insert on a standard contacts request.

    var feedUri = new Uri("https://www.google.com/m8/feeds/contacts/default/full");
    myContactsRequest.Insert(feedUri,newEntry);

Sometimes(with no changes in my code) I get this exception:

System.Net.ProtocolViolationException : When performing a write operation with 
AllowWriteStreamBuffering set to false, you must either set ContentLength to a 
non-negative number or set SendChunked to true.
   at System.Net.HttpWebRequest.CheckProtocol(Boolean onRequestStream)
   at System.Net.HttpWebRequest.GetResponse()
   at Google.GData.Client.GDataRequest.Execute()
   at Google.GData.Client.GDataGAuthRequest.Execute(Int32 retryCounter)
   at Google.GData.Client.GOAuth2Request.Execute()
   at Google.GData.Client.Service.EntrySend(Uri feedUri, AtomBase baseEntry, GDataRequestType type, AsyncSendData data)
   at Google.GData.Client.Service.Insert(Uri feedUri, AtomEntry newEntry, AsyncSendData data)
   at Google.GData.Client.Service.Insert(Uri feedUri, TEntry entry)
   at Google.GData.Client.FeedRequest`1.Insert(Uri address, Y entry)
   at covve.Providers.Tests.GmailApiLearningTests.GoogleApiCallAddContact() in GmailApiLearningTests.cs: line 124

And sometimes my code works just fine. It appears as if some non deterministic 
variable is affecting the result and the stack trace seems to be out of my 
code's scope. Note that my OAuth2properties and settings are working fine on 
myContactsRequest.GetContacts(), so I suppose it's not an authorization/token 
issue. Also, using the alternative syntax of insert:

myContactsRequest.Insert(Feed<Contact> feed, Contact)

has always worked as expected, despite the fact that both methods of insert are 
alternatives for the same functionality.

Additional info:

Google.GData.Client version: 2.2.0.0
.NET framework 4.5 (vs 2013, version 4.5.51.641)



Original issue reported on code.google.com by [email protected] on 19 May 2014 at 2:54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant