C#在SoundCloud上创建播放列表

C#在SoundCloud上创建播放列表,c#,.net,api,soundcloud,C#,.net,Api,Soundcloud,我对soundcloudapi有一些问题,希望有人能帮助我。所有的GET Methods都很完美,但现在我想在SoundCloud上创建一个新的播放列表,我收到了resonse 422,消息是“Unprocessable Entity” 这是我当前的api执行方法 private T Execute<T>(Uri url, HttpMethod method = null, object bodyParams = null) where T: class

我对soundcloudapi有一些问题,希望有人能帮助我。所有的GET Methods都很完美,但现在我想在SoundCloud上创建一个新的播放列表,我收到了resonse 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>();
    }
private T Execute(Uri url,HttpMethod=null,object bodyParams=null)
T:在哪里上课
{
var uri=url.AddParameter(“oauth_token”,uri.EscapeDataString(tokenKey)).AddParameter(“客户端id”,((SoundCloudAuthenticationOptions)AuthenticationOptions).ClientId);
var httpRequestMessage=新的httpRequestMessage(方法??HttpMethod.Get,uri);
如果(bodyParams!=null)
{
httpRequestMessage.Content=新的StringContent(JsonConvert.SerializeObject(bodyParams));
}
HttpResponseMessage response=httpClient.SendAsync(httpRequestMessage).Result;
//response.EnsureSuccessStatusCode();
var json=response.Content.ReadAsStringAsync().Result;
var jObject=jObject.Parse(json);
如果(类型(T)=类型(JObject))
将jObject返回为T;
返回jObject.ToObject();
}
对于创建播放列表,我称之为

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

我不能100%确定问题出在哪里,但我过去在SoundCloud API中使用过这个库(这个库不是没有问题的)

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

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


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

例如,如果XML请求正文包含格式正确(即语法正确),但语义错误的XML指令,则可能会出现此错误情况。可能是因为您的
曲目列表是空的吗?非常感谢,我会检查的。谢谢,我找到了一个不同的。。如果我将参数添加到url,而不是添加到正文中,它将起作用。谢谢。