From 9d5ce95abcc3648d6e02b253cdb135496af37404 Mon Sep 17 00:00:00 2001 From: RogueException Date: Sun, 13 Sep 2015 12:01:12 -0300 Subject: [PATCH] Fixed RestSharp settings --- src/Discord.Net/Net/RestClient.BuiltIn.cs | 5 +++-- src/Discord.Net/Net/RestClient.SharpRest.cs | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Discord.Net/Net/RestClient.BuiltIn.cs b/src/Discord.Net/Net/RestClient.BuiltIn.cs index 03eff9f7a..de9657aff 100644 --- a/src/Discord.Net/Net/RestClient.BuiltIn.cs +++ b/src/Discord.Net/Net/RestClient.BuiltIn.cs @@ -1,4 +1,5 @@ #if DNXCORE50 +using Discord.Net.API; using System; using System.Globalization; using System.IO; @@ -36,7 +37,7 @@ namespace Discord.Net public Task Send(HttpMethod method, string path, string json, CancellationToken cancelToken) { - using (var request = new HttpRequestMessage(method, path)) + using (var request = new HttpRequestMessage(method, Endpoints.BaseApi + path)) { if (json != null) request.Content = new StringContent(json, Encoding.UTF8, "application/json"); @@ -45,7 +46,7 @@ namespace Discord.Net } public Task SendFile(HttpMethod method, string path, string filePath, CancellationToken cancelToken) { - using (var request = new HttpRequestMessage(method, path)) + using (var request = new HttpRequestMessage(method, Endpoints.BaseApi + path)) { var content = new MultipartFormDataContent("Upload----" + DateTime.Now.ToString(CultureInfo.InvariantCulture)); content.Add(new StreamContent(File.OpenRead(filePath)), "file", Path.GetFileName(filePath)); diff --git a/src/Discord.Net/Net/RestClient.SharpRest.cs b/src/Discord.Net/Net/RestClient.SharpRest.cs index 678325d42..a8733ae87 100644 --- a/src/Discord.Net/Net/RestClient.SharpRest.cs +++ b/src/Discord.Net/Net/RestClient.SharpRest.cs @@ -1,4 +1,5 @@ #if !DNXCORE50 +using Discord.Net.API; using RestSharp; using System; using System.IO; @@ -14,7 +15,7 @@ namespace Discord.Net public SharpRestEngine(string userAgent) { - _client = new RestSharp.RestClient() + _client = new RestSharp.RestClient(Endpoints.BaseApi) { PreAuthenticate = false }; @@ -32,8 +33,8 @@ namespace Discord.Net public Task Send(HttpMethod method, string path, string json, CancellationToken cancelToken) { - var request = new RestRequest(path, GetMethod(method)) { RequestFormat = DataFormat.Json }; - request.AddBody(json); + var request = new RestRequest(path, GetMethod(method)); + request.AddParameter("application/json", json, ParameterType.RequestBody); return Send(request, cancelToken); } public Task SendFile(HttpMethod method, string path, string filePath, CancellationToken cancelToken)