Skip to content

Commit

Permalink
Hacky fix for GET Application
Browse files Browse the repository at this point in the history
  • Loading branch information
BiBi committed Jun 4, 2019
1 parent 81d57f1 commit d746057
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions Nexmo.Api/ApplicationV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,31 @@ public static AppResponse Create(AppRequest request, Credentials credentials = n
/// <returns></returns>
public static AppResponse Get(string appId, Credentials credentials = null)
{
var response = ApiRequest.DoRequest(ApiRequest.GetBaseUriFor(typeof(ApplicationV2), $"/v2/applications/{appId}"), new { }, credentials);
// This is a dirty hack for the GET requests on Application V2 to work
// until the fix on the API level is implemented.
#if (!NETSTANDARD1_6)
{
string url = ApiRequest.GetBaseUriFor(typeof(ApplicationV2), $"/v2/applications/{appId}").ToString();
string result;
var authBytes = Encoding.UTF8.GetBytes(credentials.ApiKey + ":" + credentials.ApiSecret);
using (WebClient client = new WebClient())
{
client.Headers[HttpRequestHeader.Authorization] = "Basic" + Convert.ToBase64String(authBytes);
client.Headers[HttpRequestHeader.ContentType] = "application/json";

result = client.DownloadString(url);
}
return JsonConvert.DeserializeObject<AppResponse>(result);
}

#endif

return null;

// proper solution
//var response = ApiRequest.DoRequest(ApiRequest.GetBaseUriFor(typeof(ApplicationV2), $"/v2/applications/{appId}"), credentials);

return JsonConvert.DeserializeObject<AppResponse>(response);
//return JsonConvert.DeserializeObject<AppResponse>(response);
}

/// <summary>
Expand Down

0 comments on commit d746057

Please sign in to comment.