添加曲目到播放列表的SoundCloud API [英] Add track to playlist SoundCloud API

查看:164
本文介绍了添加曲目到播放列表的SoundCloud API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Windows Phone应用程序,我用下面的code到A曲目添加到播放列表(即PUT请求到播放列表/ ID端点)

In my Windows Phone App, I'm using the following code to add a track to playlist (i.e. a PUT request to playlists/id endpoint)

    using (HttpClient httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(AccessToken);
                HttpResponseMessage response = await httpClient.PutAsync(endpoint, new StringContent(data));
                response.EnsureSuccessStatusCode();
            }

,其中数据是JSON数据的格式为:

where "data" is JSON data the form:

    {"playlist":{"tracks":["TrackId(to be added)"]}}

以上code返回OK(200)响应,但在赛道不添加到播放列表中!

The above code returns "OK"(200) response but the track is NOT added to the playlist!

我是什么做错了吗?粘贴了两天。在此先感谢!

What am I doing wrong? Stuck on it for two days. Thanks in advance!

推荐答案

的问题是,(请求体)的JSON数据的格式不正确。
数据的形式必须的:

The problem was that the JSON data (of the request body) was not formatted correctly. "data" must be of the form:

    {"playlist":{"tracks":[{"id":"__"}, {"id":"__"}, {"id":"__"}]}}

下面的ID值对必须是present

Here the id-value pair must be present for


  • 每个轨道已经present播放列表,以及

  • every track already present in the playlist, as well as

要添加到播放列表曲目

(请记住,这是一个PUT请求。所以,你需要更新数据,即更新轨迹中的播放列表的属性)

(Remember, this is a PUT request. So, you need to update data i.e. update the "tracks" property of the "playlist")

这篇关于添加曲目到播放列表的SoundCloud API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆