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

Company Get (List) fails after Company Update #11

Open
AGBrown opened this issue Jun 2, 2014 · 0 comments
Open

Company Get (List) fails after Company Update #11

AGBrown opened this issue Jun 2, 2014 · 0 comments

Comments

@AGBrown
Copy link

AGBrown commented Jun 2, 2014

Environment: .NET 4.5 in VS2013
Requests captured using Fiddler
Possible (nasty?) fix: Make Company.CreatedAt a DateTime? instead of a DateTime (however see note at the end).
Issue: After updating a company using the code below, the final request to get a list of companies fails, if the updated company is in the block of companies requested

company.Tags.Add(newTag);
company.Tags.Add(oldTag);
api.CompanyRequest.Update(company);
api.CompanyRequest.Get(offset:(int?)currentBlock); // now this fails

Diagnosis:
RestSharp is actually the component throwing the exception. The company is updated with a value in the PUT of <created-at>30/05/2014 14:07:07</created-at> (for example), but is then returned in the GET xml with <created-at type="datetime" nil="true"></created-at>. The nil DateTime appears to then throw an exception within RestSharp:

Message: "String was not recognized as a valid DateTime."
Stacktrace:    at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
   at System.DateTime.Parse(String s, IFormatProvider provider)
   at RestSharp.Deserializers.XmlDeserializer.Map(Object x, XElement root)
   at RestSharp.Deserializers.XmlDeserializer.CreateAndMap(Type t, XElement element)
   at RestSharp.Deserializers.XmlDeserializer.PopulateListFromElements(Type t, IEnumerable`1 elements, IList list)
   at RestSharp.Deserializers.XmlDeserializer.HandleListDerivative(Object x, XElement root, String propName, Type type)
   at RestSharp.Deserializers.XmlDeserializer.Deserialize[T](IRestResponse response)
   at RestSharp.RestClient.Deserialize[T](IRestRequest request, IRestResponse raw)

While changing Company.CreatedAt to public DateTime? CreatedAt { get; set; } allows all the companies to be returned in the block, that then creates a new issue: updating a company by api.CompanyRequest.Update(company) removes the value of CreatedAt.

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

No branches or pull requests

1 participant