在SoundCloud上创建一个播放列表



我有一些问题与soundcloudapi,我希望有人能帮助我。所有GET方法工作完美,但现在我想在SoundCloud上创建一个新的播放列表,我总是收到响应422消息"Unprocessable Entity"

这是我当前的api执行方法

      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>();
    }

对于创建播放列表,我称之为

Execute<JObject>(apiUrl.Append("playlists"), HttpMethod.Post, new { playlist = new { title = name, sharing = "private", tracks = new string[0] } })

我不是100%确定问题是什么,但我已经使用这个库在过去的SoundCloud API(库不来没有它的问题)

https://github.com/Haythem/SoundCloud.NET

你可以看一下那里,看看他们是怎么做的。

另一方面,我只是在SoundCloud网站上玩了玩,并测试了使用chrome开发人员工具创建一些播放列表-我发现创建没有曲目的播放列表是不允许的。

您可能只是想尝试使用非空轨道列表执行命令。

相关内容

最新更新