Dhruti90 / google-gdata1111

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

C# library does not set HTTP header X-Redirect-Calendar-Shard: true #319

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. get a calendar event using the c# calender api library (1.4.0.2, the
latest I can download, even though it's very old?)
2. update some parts, and add a 'SyncEvent' (I'm trying to write something
to sync two calendering systems), e.g. like in this bit of test code:
[..]
EventFeed calFeed = service.Query(query) as EventFeed;
EventEntry entry = (EventEntry) calFeed.Entries[0];
if ( entry.SyncEvent == null )
{
    entry.SyncEvent = new GCalSyncEvent();
}
entry.SyncEvent.BooleanValue = true;
entry.Sequence.IntegerValue = entry.Sequence.IntegerValue + 5;
entry.Update();

3. Compile and run

What is the expected output? What do you see instead?

I would expect the C# api to do whatever is needed to make this work.
Instead, I get an exception telling me "syncEvent requires the
X-Redirect-Calendar-Shard header". (Note that there are several requests in
user groups on how to do this, all unanswered. As far as I can understand,
the C# library should be smart enough to add this header when needed. But a
way to add it 'manually' would help too.)

Original issue reported on code.google.com by arnt.wit...@gmail.com on 21 Jan 2010 at 10:06

GoogleCodeExporter commented 9 years ago
After browsing the source code here at length, I've come up with:
((GDataRequestFactory) entry.Service.RequestFactory).CustomHeaders.Add(
"X-Redirect-Calendar-Shard: true" );

Is this correct (it appears to work at first sight).

Original comment by arnt.wit...@gmail.com on 21 Jan 2010 at 10:53

GoogleCodeExporter commented 9 years ago
The custom headers property is exactly for that purpose: if you need to send a 
custom header, because either a 
service suddenly demands one, or for any other reason.

Original comment by fman...@gmail.com on 1 Feb 2010 at 8:51

GoogleCodeExporter commented 9 years ago
Ok, I understand. 2 comments however:
- how to add headers was impossible to find in the docs or on the web. I hope 
this
issue can now help others.
- I guess the design of the libraries is to be as light as possible, so the 
server
code can change and the libraries won't have to? (But the apps using the 
libraries
would still need to change.) Because to me, the purpose of having such a library
seems to be to shield its users from having to know that if syncevent!=null you 
need
to add a header and where to add it... So I still think that having the library 
add
it when needed would be helpful to every one.

Original comment by arnt.wit...@gmail.com on 1 Feb 2010 at 7:12