Skip to content

Commit c89e5ac

Browse files
committed
Merge pull request #191 from CrustyJew/master
Fix Edit Wiki Page without previous revision ID
2 parents 84e04ce + a252245 commit c89e5ac

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

RedditSharp/Wiki.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,24 @@ public Listing<Post> GetPageDiscussions(string page)
102102
public void EditPage(string page, string content, string previous = null, string reason = null)
103103
{
104104
var request = WebAgent.CreatePost(string.Format(WikiPageEditUrl, Subreddit.Name));
105-
WebAgent.WritePostBody(request.GetRequestStream(), new
105+
dynamic param = new
106106
{
107107
content = content,
108-
previous = previous,
109-
reason = reason,
110108
page = page,
111109
uh = Reddit.User.Modhash
112-
});
110+
};
111+
List<string> addParams = new List<string>();
112+
if (previous != null)
113+
{
114+
addParams.Add("previous");
115+
addParams.Add(previous);
116+
}
117+
if (reason != null)
118+
{
119+
addParams.Add("reason");
120+
addParams.Add(reason);
121+
}
122+
WebAgent.WritePostBody(request.GetRequestStream(), param,addParams.ToArray());
113123
var response = request.GetResponse();
114124
}
115125

0 commit comments

Comments
 (0)