Skip to content

Commit e77fd46

Browse files
Merge pull request #282 from sendgrid/256-bad-json
256 bad json
2 parents 7d04be3 + 9d48986 commit e77fd46

File tree

38 files changed

+878
-378
lines changed

38 files changed

+878
-378
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
## [7.0.7] - 2016-07-18
5+
- Fix for [issue #256](https://github.com/sendgrid/sendgrid-csharp/issues/256): SendGrid v3 and HTML emails - Creates bad Json
6+
- Updated dependency to SendGrid.Csharp.HTTP.Client to 2.0.6
7+
- Updated dependency to JSON.NET to 9.0.1 in the Example and SendGrid projects
8+
- Removed dependencies to SendGrid.CSharp.HTTP.Client and SendGrid.SmtpApi from the Example and UnitTests projects as they are not needed
9+
- Update examples, unit tests and USAGE.md to pass in valid JSON
10+
- Thanks to [Gunnar Liljas](https://github.com/gliljas) for helping find the root cause quickly!
11+
412
## [7.0.6] - 2016-07-12
513
### Added
614
- Update docs, unit tests and examples to include Sender ID

SendGrid/Example/Example.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Web.Script.Serialization;
44
using SendGrid.Helpers.Mail;
5+
using Newtonsoft.Json;
56

67
namespace Example
78
{
@@ -31,15 +32,12 @@ private static void HelloEmail()
3132
Email email = new Email("[email protected]");
3233
mail.Personalization[0].AddTo(email);
3334

34-
String ret = mail.Get();
35-
36-
string requestBody = ret;
37-
dynamic response = sg.client.mail.send.post(requestBody: requestBody);
35+
dynamic response = sg.client.mail.send.post(requestBody: mail.Get());
3836
Console.WriteLine(response.StatusCode);
3937
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
4038
Console.WriteLine(response.Headers.ToString());
4139

42-
Console.WriteLine(ret);
40+
Console.WriteLine(mail.Get());
4341
Console.ReadLine();
4442

4543
}
@@ -231,15 +229,12 @@ private static void KitchenSink()
231229
email.Address = "[email protected]";
232230
mail.ReplyTo = email;
233231

234-
String ret = mail.Get();
235-
236-
string requestBody = ret;
237-
dynamic response = sg.client.mail.send.post(requestBody: requestBody);
232+
dynamic response = sg.client.mail.send.post(requestBody: mail.Get());
238233
Console.WriteLine(response.StatusCode);
239234
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
240235
Console.WriteLine(response.Headers.ToString());
241236

242-
Console.WriteLine(ret);
237+
Console.WriteLine(mail.Get());
243238
Console.ReadLine();
244239
}
245240

@@ -268,7 +263,8 @@ private static void ApiKeys()
268263
'alerts.read'
269264
]
270265
}";
271-
response = sg.client.api_keys.post(requestBody: requestBody);
266+
Object json = JsonConvert.DeserializeObject<Object>(requestBody);
267+
response = sg.client.api_keys.post(requestBody: json.ToString());
272268
Console.WriteLine(response.StatusCode);
273269
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
274270
Console.WriteLine(response.Headers.ToString());
@@ -292,7 +288,8 @@ private static void ApiKeys()
292288
requestBody = @"{
293289
'name': 'A New Hope'
294290
}";
295-
response = sg.client.api_keys._(api_key_id).patch(requestBody: requestBody);
291+
json = JsonConvert.DeserializeObject<Object>(requestBody);
292+
response = sg.client.api_keys._(api_key_id).patch(requestBody: json.ToString());
296293
Console.WriteLine(response.StatusCode);
297294
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
298295
Console.WriteLine(response.Headers.ToString());
@@ -308,7 +305,8 @@ private static void ApiKeys()
308305
' user.profile.update'
309306
]
310307
}";
311-
response = sg.client.api_keys._(api_key_id).put(requestBody: requestBody);
308+
json = JsonConvert.DeserializeObject<Object>(requestBody);
309+
response = sg.client.api_keys._(api_key_id).put(requestBody: json.ToString());
312310
Console.WriteLine(response.StatusCode);
313311
Console.WriteLine(response.Body.ReadAsStringAsync().Result);
314312
Console.WriteLine(response.Headers.ToString());

SendGrid/Example/Example.csproj

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,10 @@
4646
</PropertyGroup>
4747
<ItemGroup>
4848
<Reference Include="Microsoft.CSharp" />
49-
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
50-
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
49+
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
50+
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
5151
<Private>True</Private>
5252
</Reference>
53-
<Reference Include="SendGrid.CSharp.HTTP.Client, Version=2.0.4.0, Culture=neutral, PublicKeyToken=79219bf4e5ecaaca, processorArchitecture=MSIL">
54-
<HintPath>..\packages\SendGrid.CSharp.HTTP.Client.2.0.4\lib\SendGrid.CSharp.HTTP.Client.dll</HintPath>
55-
<Private>True</Private>
56-
</Reference>
57-
<Reference Include="SendGrid.SmtpApi, Version=1.3.1.0, Culture=neutral, PublicKeyToken=2ae73662c35d80e4, processorArchitecture=MSIL">
58-
<SpecificVersion>False</SpecificVersion>
59-
<HintPath>..\packages\SendGrid.SmtpApi.1.3.1\lib\net40\SendGrid.SmtpApi.dll</HintPath>
60-
</Reference>
6153
<Reference Include="System" />
6254
<Reference Include="System.Data.DataSetExtensions" />
6355
<Reference Include="System.Net" />

SendGrid/Example/app.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</dependentAssembly>
2020
<dependentAssembly>
2121
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
22-
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
22+
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
2323
</dependentAssembly>
2424
</assemblyBinding>
2525
</runtime>

SendGrid/Example/packages.config

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
4-
<package id="SendGrid.CSharp.HTTP.Client" version="2.0.4" targetFramework="net452" />
3+
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
54
</packages>

SendGrid/SendGrid/App.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
88
<dependentAssembly>
99
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
10-
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
10+
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
1111
</dependentAssembly>
1212
</assemblyBinding>
1313
</runtime>

SendGrid/SendGrid/SendGrid.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343
<AssemblyOriginatorKeyFile>sendgrid-csharp.snk</AssemblyOriginatorKeyFile>
4444
</PropertyGroup>
4545
<ItemGroup>
46-
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
47-
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
46+
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
47+
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
4848
<Private>True</Private>
4949
</Reference>
50-
<Reference Include="SendGrid.CSharp.HTTP.Client, Version=2.0.4.0, Culture=neutral, PublicKeyToken=79219bf4e5ecaaca, processorArchitecture=MSIL">
51-
<HintPath>..\packages\SendGrid.CSharp.HTTP.Client.2.0.4\lib\SendGrid.CSharp.HTTP.Client.dll</HintPath>
50+
<Reference Include="SendGrid.CSharp.HTTP.Client, Version=2.0.6.0, Culture=neutral, PublicKeyToken=79219bf4e5ecaaca, processorArchitecture=MSIL">
51+
<HintPath>..\packages\SendGrid.CSharp.HTTP.Client.2.0.6\lib\SendGrid.CSharp.HTTP.Client.dll</HintPath>
5252
<Private>True</Private>
5353
</Reference>
5454
<Reference Include="System" />

SendGrid/SendGrid/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net45" />
4-
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
5-
<package id="SendGrid.CSharp.HTTP.Client" version="2.0.4" targetFramework="net452" />
4+
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
5+
<package id="SendGrid.CSharp.HTTP.Client" version="2.0.6" targetFramework="net452" />
66
</packages>

0 commit comments

Comments
 (0)