From 49f33828f582826f3a606000d4a7fd8e165e34f9 Mon Sep 17 00:00:00 2001 From: Ryan Kistner Date: Sat, 27 Apr 2019 19:08:20 -0600 Subject: [PATCH] Leave null WebAPI args defined but empty --- Samples/6.WebAPI/Program.cs | 2 +- SteamKit2/SteamKit2/Steam/WebAPI/WebAPI.cs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Samples/6.WebAPI/Program.cs b/Samples/6.WebAPI/Program.cs index df01c03d6..9efdb6761 100644 --- a/Samples/6.WebAPI/Program.cs +++ b/Samples/6.WebAPI/Program.cs @@ -92,7 +92,7 @@ static void Main( string[] args ) // you can call interface functions through a Call method using ( WebAPI.Interface steamNews = WebAPI.GetInterface( "ISteamNews" ) ) { - Dictionary newsArgs = new Dictionary(); + Dictionary newsArgs = new Dictionary(); newsArgs[ "appid" ] = "440"; KeyValue results = steamNews.Call( "GetNewsForApp", /* version */ 1, newsArgs ); diff --git a/SteamKit2/SteamKit2/Steam/WebAPI/WebAPI.cs b/SteamKit2/SteamKit2/Steam/WebAPI/WebAPI.cs index 64cadff54..78369142f 100644 --- a/SteamKit2/SteamKit2/Steam/WebAPI/WebAPI.cs +++ b/SteamKit2/SteamKit2/Steam/WebAPI/WebAPI.cs @@ -272,9 +272,13 @@ async Task CallAsyncCore( HttpMethod method, string func, int version string key = HttpUtility.UrlEncode( kvp.Key ); string value; - if ( kvp.Value is byte[] ) + if ( kvp.Value == null ) { - value = HttpUtility.UrlEncode( kvp.Value as byte[] ); + value = string.Empty; + } + else if ( kvp.Value is byte[] buffer ) + { + value = HttpUtility.UrlEncode( buffer ); } else {