C# Linkedin api帖子不起作用?

C# Linkedin api帖子不起作用?,c#,asp.net-mvc,api,asp.net-mvc-4,C#,Asp.net Mvc,Api,Asp.net Mvc 4,公共操作结果授权LinkedIn(字符串代码、字符串状态、字符串错误、字符串错误\u说明) { //Linkedin 如果(!string.IsNullOrEmpty(错误)| |!string.IsNullOrEmpty(错误描述)) { //处理错误和错误描述 } 其他的 { objusermodel=新用户模型(); var host=ExtractHost(); var_redirectUrl=Url.Action(“authorizedLinkedIn”,“Investments”,n

公共操作结果授权LinkedIn(字符串代码、字符串状态、字符串错误、字符串错误\u说明) { //Linkedin 如果(!string.IsNullOrEmpty(错误)| |!string.IsNullOrEmpty(错误描述)) { //处理错误和错误描述 } 其他的 { objusermodel=新用户模型(); var host=ExtractHost(); var_redirectUrl=Url.Action(“authorizedLinkedIn”,“Investments”,null,Request.Url.Scheme,host); var userToken=api.OAuth2.GetAccessToken(代码,\u重定向URL); //为您的API请求保留此令牌 var user=newuserauthorization(userToken.AccessToken); var fields=FieldSelector.For().WithFirstName().WithFollowing(); if(会话[“ShareResponse”]!=null) { shareResponse=Session.GetObjectFromJson(“shareResponse”); } //试一试 //{

    var profile = api.Profiles.GetMyProfile(user, new string[] { "en-US" }, fields);
    api.Social.Post(user, new PostShare()
    {
        Content = new PostShareContent()
        {
            Title = "FUNDING PORTAL",
            Description = shareResponse.Message,
            SubmittedUrl = shareResponse.ShareUrl,
            SubmittedImageUrl = shareResponse.ImageUrl,
        },
        Visibility = new Visibility()
        {
            Code = "anyone"

        },
    });

    shareResponse.Success = 1;
    shareResponse.flag = true;
    Session.SetObjectAsJson("ShareResponse", shareResponse);
    TempData["PromoboxFN"] = shareResponse.ImageUrl;
    TempData.Keep("PromoboxFN");
    return Redirect(shareResponse.RedirectUrl);
    //}
    //catch (Exception ex)
    //{
    //    throw;
    //    shareResponse.Success = 0;
    //    shareResponse.flag = true;
    //    Session.SetObjectAsJson("ShareResponse", shareResponse);
    //    return Redirect(shareResponse.RedirectUrl);
    //}

}
return null;
}

给出错误:

“api.Social.Post(user,new PostShare()”到目前为止 在中出现类型“Sparkle.LinkedInNET.LinkedInApiException” Sparkle.LinkedInNET.dll,但未在用户代码中处理


附加信息:API错误(500)
处的内部服务错误在Sparkle.LinkedInNET.dll中发生了类型为'Sparkle.LinkedInNET.LinkedInApiException'的异常,但未在用户代码中处理,再加上您注释掉的
catch
语句意味着您不知道问题出在哪里。取消对catch块的注释,捕获
LinkInApiException
看看它告诉了你什么。我使用try-catch-and-get-error,比如:API错误(500)内部服务错误。你看了500内部错误是什么吗?它是服务器端的,这意味着API有问题。。。。