I'm using the C# SDK and it seems that there is a bug when executing any POST. The post body is serialized as the string "System.IO.StringReader". This seems to be because of line 127 in Internal/Http/DefaultHttpClient.cs
I changed the code from:
restRequest.AddParameter("application/json", smartsheetRequest.Entity.GetContent(),ParameterType.RequestBody);
to:
restRequest.AddParameter("application/json", smartsheetRequest.Entity.GetContent().ReadToEnd(),ParameterType.RequestBody);
and it seems to fix the problem. Could someone from Smartsheet check and confirm please?
Thx
Thanks for bringing this to our attention! We were able to include the fix for this in a release that we pushed out today. Just upgrade your package using NuGet or download the latest source code from Github.
The list of changes for this release are:
Techinical Details
This issue was introduced on March 17th two days before we released version 1.0.1 and specifically was caused by the commit 2d69ef5b8f95dbe911d9bb1ecb50a6a441b522b5 where the ReadToEnd() method was removed in order to support binary attachments.
This issue was caused by the line that you pointed to where the
smartsheetRequest.Entity.GetContent()was allowing the restRequest object to call ToString() which gave us a request body like the following:The last line should have been the real content of the StreamReader not the ToString() of the StreamReader.
The solution you mentioned of using ReadToEnd() on the StreamReader was a good one except that it does not handle binary data. We implemented this change by using the
GetBinaryContent()method. Then we converted it to a byte array by usingUtil.ReadAllBytes(...).The exact changes are listed below in diff format: