diff --git a/HubSpot.NET/Api/OAuth/HubSpotOAuthApi.cs b/HubSpot.NET/Api/OAuth/HubSpotOAuthApi.cs index a9aa5469..771246cf 100644 --- a/HubSpot.NET/Api/OAuth/HubSpotOAuthApi.cs +++ b/HubSpot.NET/Api/OAuth/HubSpotOAuthApi.cs @@ -103,20 +103,16 @@ private HubSpotToken InitiateRequest(K model, string basePath, params OAuthSc JsonSerializer = new FakeSerializer() }; + request.AddHeader("Content-Type", "application/x-www-form-urlencoded"); + Dictionary jsonPreStringPairs = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(model)); StringBuilder bodyBuilder = new StringBuilder(); foreach(KeyValuePair pair in jsonPreStringPairs) { - if (bodyBuilder.Length > 0) - { bodyBuilder.Append("&"); } - - bodyBuilder.Append($"{pair.Key}={pair.Value}"); + request.AddParameter(pair.Key, pair.Value); } - request.AddJsonBody(bodyBuilder.ToString()); - request.AddHeader("ContentType", "application/x-www-form-urlencoded"); - if (builder.Length > 0) request.AddQueryParameter("scope", builder.ToString());