I have some problems with the soundcloudapi and I hope someone can help me. All GET Methods work perfectly, but now I want to create a new playlist on SoundCloud and I always receive response 422 with message:
"Unprocessable Entity"
This is my current API execution method:
private T Execute<T>(Uri url, HttpMethod method = null, object bodyParams = null)
where T: class
{
var uri = url.AddParameter("oauth_token", Uri.EscapeDataString(tokenKey)).AddParameter("client_id", ((SoundCloudAuthenticationOptions)AuthenticationOptions).ClientId);
var httpRequestMessage = new HttpRequestMessage(method ?? HttpMethod.Get, uri);
if (bodyParams != null)
{
httpRequestMessage.Content = new StringContent(JsonConvert.SerializeObject(bodyParams));
}
HttpResponseMessage response = httpClient.SendAsync(httpRequestMessage).Result;
// response.EnsureSuccessStatusCode();
var json = response.Content.ReadAsStringAsync().Result;
var jObject = JObject.Parse(json);
if (typeof (T) == typeof (JObject))
return jObject as T;
return jObject.ToObject<T>();
}
And for creating a playlist I call it like
Execute<JObject>(apiUrl.Append("playlists"), HttpMethod.Post, new { playlist = new { title = name, sharing = "private", tracks = new string[0] } })
tracks
list is empty?