wp-net / WordPressPCL

This is a portable library for consuimg the WordPress REST-API in (almost) any C# application
MIT License
338 stars 129 forks source link

there is an error when create a post by restapi #178

Closed benbenfa closed 3 years ago

benbenfa commented 5 years ago

hello dear author,your wordpresspcl is very good ,i very like it ,just now i found that when i create a post there is an unexception error,and i try the test project ,can't pass too, because when a post created a result like below returned ,but can't be prased by Newttonsoft.Json,

return as follow this is not a pure json return:

文档已移动

对象已移动

可在此处找到该文档

{"id":468,"date":"2019-08-15T10:31:00","date_gmt":"2019-08-15T02:31:00","guid":{"rendered":"http:\/\/www.jhcms.net\/index.php\/2019\/08\/15\/xx-17\/","raw":"http:\/\/www.jhcms.net\/index.php\/2019\/08\/15\/xx-17\/"},"modified":"2019-08-15T10:31:00","modified_gmt":"2019-08-15T02:31:00","password":"","slug":"xx-17","status":"publish","type":"post","link":"http:\/\/www.jhcms.net\/index.php\/2019\/08\/15\/xx-17\/","title":{"raw":"rest api\u53d1\u5e03post\u6d4b\u8bd5","rendered":"rest api\u53d1\u5e03post\u6d4b\u8bd5"},"content":{"raw":" \u7cfb\u7edf\u6d4b\u8bd5\u6211b>@<\/b\u60f3\u6211\u662f\u6d77\u51ac\u5929\u7684\u5927\u6d77 \u6d4b\u8bd5\u4e0d\u6210\u529f<\/font>","rendered":"

\u7cfb\u7edf\u6d4b\u8bd5\u6211b>@<\/b\u60f3\u6211\u662f\u6d77\u51ac\u5929\u7684\u5927\u6d77 \u6d4b\u8bd5\u4e0d\u6210\u529f<\/font><\/p>\n<div style=\"clear:both; border-top:1px dashed #e0e0e0; padding:10px 0 10px 0; font-size:12px;\">\u7248\u6743\u6240\u6709\u00a9\u8f6c\u8f7d\u5fc5\u987b\u4ee5\u94fe\u63a5\u5f62\u5f0f\u6ce8\u660e\u4f5c\u8005\u548c\u539f\u59cb\u51fa\u5904\uff1a<a href=\"http:\/\/www.jhcms.net\" title=\"\u70b9\u51fb\u53bb\u9996\u9875\">\u6c5f\u6e56\u6e90\u7801<\/a> \u00bb <a title=\"\u672c\u6587\u5730\u5740\" href=\"http:\/\/www.jhcms.net\/index.php\/2019\/08\/15\/xx-17\/\">rest api\u53d1\u5e03post\u6d4b\u8bd5<\/a><\/div>","protected":false,"block_version":0},"excerpt":{"raw":"","rendered":"

\u7cfb\u7edf\u6d4b\u8bd5\u6211@\u60f3\u6211\u662f\u6d77\u51ac\u5929\u7684\u5927\u6d77 \u6d4b\u8bd5\u4e0d\u6210\u529f \u7248\u6743\u6240\u6709\u00a9\u8f6c\u8f7d\u5fc5\u987b\u4ee5\u94fe\u63a5\u5f62\u5f0f\u6ce8\u660e\u4f5c\u8005\u548c\u539f\u59cb\u51fa\u5904\uff1a\u6c5f\u6e56\u6e90\u7801 \u00bb re … <a href=\"http:\/\/www.jhcms.net\/index.php\/2019\/08\/15\/xx-17\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201crest api\u53d1\u5e03post\u6d4b\u8bd5\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"permalink_template":"http:\/\/www.jhcms.net\/index.php\/2019\/08\/15\/%postname%\/","generated_slug":"rest-api\u53d1\u5e03post\u6d4b\u8bd5","_links":{"self":[{"href":"http:\/\/www.jhcms.net\/index.php\/wp-json\/wp\/v2\/posts\/468"}],"collection":[{"href":"http:\/\/www.jhcms.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.jhcms.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.jhcms.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.jhcms.net\/index.php\/wp-json\/wp\/v2\/comments?post=468"}],"version-history":[{"count":0,"href":"http:\/\/www.jhcms.net\/index.php\/wp-json\/wp\/v2\/posts\/468\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.jhcms.net\/index.php\/wp-json\/wp\/v2\/media?parent=468"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.jhcms.net\/index.php\/wp-json\/wp\/v2\/categories?post=468"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.jhcms.net\/index.php\/wp-json\/wp\/v2\/tags?post=468"}],"wp:action-publish":[{"href":"http:\/\/www.jhcms.net\/index.php\/wp-json\/wp\/v2\/posts\/468"}],"wp:action-unfiltered-html":[{"href":"http:\/\/www.jhcms.net\/index.php\/wp-json\/wp\/v2\/posts\/468"}],"wp:action-sticky":[{"href":"http:\/\/www.jhcms.net\/index.php\/wp-json\/wp\/v2\/posts\/468"}],"wp:action-assign-author":[{"href":"http:\/\/www.jhcms.net\/index.php\/wp-json\/wp\/v2\/posts\/468"}],"wp:action-create-categories":[{"href":"http:\/\/www.jhcms.net\/index.php\/wp-json\/wp\/v2\/posts\/468"}],"wp:action-assign-categories":[{"href":"http:\/\/www.jhcms.net\/index.php\/wp-json\/wp\/v2\/posts\/468"}],"wp:action-create-tags":[{"href":"http:\/\/www.jhcms.net\/index.php\/wp-json\/wp\/v2\/posts\/468"}],"wp:action-assign-tags":[{"href":"http:\/\/www.jhcms.net\/index.php\/wp-json\/wp\/v2\/posts\/468"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}

ThomasPe commented 4 years ago

I assume you're running on IIS / Azure? Take a look here, you'll need to clean up the response before it can be parsed: https://github.com/wp-net/WordPressPCL/wiki/HttpResponsePreProcessing#wordpress-on-azure--iss

ThomasPe commented 3 years ago

I’m closing this issue because it has been inactive for a while. Please feel free to reopen if you still encounter this issue. Thanks!