当我尝试使用 Reddit API 和 RedditSharp 包装器在 post 上设置天赋时,我得到了 404
I'm getting a 404 when trying to set the flair on a post with the Reddit API and RedditSharp wrapper
我创建的一个机器人提交了 this post to /r/GamingNewsTest. I'm using the RedditSharp 包装器,当我尝试调用 `SetFlair' 时,发生了 404 异常。
这是我目前正在测试的代码:
subreddit.SubmitPost(redditPost.Title, redditPost.URL, "", "", true).SetFlair("Hearthstone", "");
我检查了包装器发送到 reddit API 的参数:
- api_type :
json
- css_class :
- link :
t3_4e44j3
- 姓名:
GamingNewsBot
- 正文:
Hearthstone
- 呃/X-Modhash header:不知道。包装器在内部处理这个。不确定如何在不进入程序集的情况下抓住它。
我没有向 css_class
传递任何内容,因为目前没有关联的 class。我可以不用手动设置。我需要传递一些东西给它吗?为什么会发生这种情况还有其他想法吗?
原因是 RedditSharp 中的错误。当您这样做时:
var post = subreddit.SubmitPost(title, url, "", "", true);
返回 post 已将 SubredditName
属性 设置为空。当你然后做
post.SetFlair("Hearthstone", "");
post数据正确但错误url:因为 SubredditName 为空,post数据/r//api/flair
,因此 404 错误。
临时解决方法是在设置 flair 之前设置此 属性:
post.SubredditName = subreddit.Name;
post.SetFlair("Hearthstone", "");
从长远来看,您必须与该库的开发人员联系并请他修复此错误。
我创建的一个机器人提交了 this post to /r/GamingNewsTest. I'm using the RedditSharp 包装器,当我尝试调用 `SetFlair' 时,发生了 404 异常。
这是我目前正在测试的代码:
subreddit.SubmitPost(redditPost.Title, redditPost.URL, "", "", true).SetFlair("Hearthstone", "");
我检查了包装器发送到 reddit API 的参数:
- api_type :
json
- css_class :
- link :
t3_4e44j3
- 姓名:
GamingNewsBot
- 正文:
Hearthstone
- 呃/X-Modhash header:不知道。包装器在内部处理这个。不确定如何在不进入程序集的情况下抓住它。
我没有向 css_class
传递任何内容,因为目前没有关联的 class。我可以不用手动设置。我需要传递一些东西给它吗?为什么会发生这种情况还有其他想法吗?
原因是 RedditSharp 中的错误。当您这样做时:
var post = subreddit.SubmitPost(title, url, "", "", true);
返回 post 已将 SubredditName
属性 设置为空。当你然后做
post.SetFlair("Hearthstone", "");
post数据正确但错误url:因为 SubredditName 为空,post数据/r//api/flair
,因此 404 错误。
临时解决方法是在设置 flair 之前设置此 属性:
post.SubredditName = subreddit.Name;
post.SetFlair("Hearthstone", "");
从长远来看,您必须与该库的开发人员联系并请他修复此错误。