Open lazardanlucian opened 9 months ago
This is a grab of a request made by the library on the update procedure/function ====== is redacted data
POST /blog/wp-json/wp/v2/posts/51 HTTP/1.1 Content-Type: application/json; charset=utf-8 Host: ====== Content-Length: 7502 Expect: 100-continue Connection: Keep-Alive
{"date":"2018-03-12T08:30:00","date_gmt":"2018-03-12T08:30:00","guid":{"rendered":"http://www.======.net/blog/?p=51","raw":null},"modified":"2018-03-12T08:33:28","modified_gmt":"2018-03-12T08:33:28","password":null,"slug":"2018-tech-trends","status":"publish","type":"post","title":{"rendered":"2018 Tech Trends","raw":null},"link":"https://======/blog/2018/03/12/2018-tech-trends/","content":{"protected":false,"rendered":"
======<a href=\"https://======\" rel=\"attachment wp-att-19256\">======
\r\n\r\n====== ..............................
the rest of the json is not needed to see that it's sending malformed data/arguments for post update
@lazardanlucian Can you please post an excerpt of the code you're using?
Using the following snippet works just fine on my end:
var post = new Post
{
Id = 18,
Title = new Title("Updated Title"),
Content = new Content
{
Raw = "Updated Post Content"
}
};
var response = await client.Posts.UpdateAsync(post);
hello @simonhammes , I don't really have it on me, It was someone else on that end, I was on wordpress end. Anyway, what I can tell you, he was grabbing a post with PCL then modifying content, then putting it back.
Updating a post seems to not work, The issue is that POST /wp-json/wp/v2/posts/%ID% expects a specific set of arguments and values like: {"title":"mytitle", "content":"mycontent"}
Instead, the library seems to grab a GET /wp-json/wp/v2/posts/%ID% which is like so: {"title":{"rendered":"mytitle"}, "content":{"rendered":"
mycontent
"}}Then feeds it back to POST /wp-json/wp/v2/posts/%ID%
The library should GET /wp-json/wp/v2/posts/%ID%?context=edit
then grab title->raw content->raw excerpt->raw (etcetera) and modify those if needed by user of library
then put them for POST /wp-json/wp/v2/posts/%ID% as {"titlle":"modified title", "content":"modified content", "excerpt": "modified excerpt"}
Thanks