|
@@ -167,10 +167,12 @@ namespace B2Uploader
|
167
|
167
|
|
168
|
168
|
static string MakeWebRequest<T>(string url, List<Tuple<string,string>> headers, T item, string contentType = "application/json; charset=utf-8")
|
169
|
169
|
{
|
|
170
|
+ string body = string.Empty;
|
|
171
|
+ byte[] data;
|
170
|
172
|
try
|
171
|
173
|
{
|
172
|
174
|
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
|
173
|
|
- byte[] data;
|
|
175
|
+
|
174
|
176
|
|
175
|
177
|
if (typeof(T) == typeof(byte[]))
|
176
|
178
|
{
|
|
@@ -178,7 +180,7 @@ namespace B2Uploader
|
178
|
180
|
}
|
179
|
181
|
else
|
180
|
182
|
{
|
181
|
|
- string body = JsonConvert.SerializeObject(item);
|
|
183
|
+ body = JsonConvert.SerializeObject(item);
|
182
|
184
|
|
183
|
185
|
data = Encoding.UTF8.GetBytes(body);
|
184
|
186
|
}
|
|
@@ -207,6 +209,14 @@ namespace B2Uploader
|
207
|
209
|
{
|
208
|
210
|
Console.WriteLine("Error talking to server: {0}", ex.Message);
|
209
|
211
|
Console.WriteLine("URL: {0}", url);
|
|
212
|
+ if (string.IsNullOrWhiteSpace(body))
|
|
213
|
+ {
|
|
214
|
+ Console.WriteLine("Byte array sent in... ");
|
|
215
|
+ }
|
|
216
|
+ else
|
|
217
|
+ {
|
|
218
|
+ Console.WriteLine("Body: {0}", body);
|
|
219
|
+ }
|
210
|
220
|
throw;
|
211
|
221
|
}
|
212
|
222
|
|