wp-net / WordPressPCL

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

Create new Post return NULL #82

Closed sonnd9x closed 6 years ago

sonnd9x commented 6 years ago

I'm trying create new post, but sometimes It return null

string _path = HttpContext.Current.Server.MapPath(post.THUMBNAIL); string extension = Path.GetExtension(_path); string _imagename = HelperExtensions.ConvertSlug(post.TITLE); var thumbnail = await client.Media.Create(_path, _imagename + extension); Post _post = new WordPressPCL.Models.Post { Title = new Title(post.TITLE), Content = new Content(post.CONTENT), Categories = new int[] { cat.CAT_ID.Value }, Excerpt = new Excerpt(post.SHORT_CONTENT), Status = Status.Publish, Date = DateTime.Now }; if (thumbnail != null) _post.FeaturedMedia = thumbnail.Id; var posted = await client.Posts.Create(_post);

polushinmk commented 6 years ago

You said, that sometimes it returns null but sometimes all OK? I`l try to reproduce your scenario and for me it works correctly. Media and Post creates. Could you trace failed requests and responces? You can use fiddler for that task, or may be some another http web debugging software

sonnd9x commented 6 years ago

I checked, thumbnail was successfully created, but create post function return null. I tried many times, it still return null.

polushinmk commented 6 years ago

Could you provide site address and sample data (Title, content, etc)? And, if you could, trace http requests using fiddler.

sonnd9x commented 6 years ago

How can I send you sample data test?

sonnd9x commented 6 years ago

HTTP/1.1 302 Found Cache-Control: private, s-maxage=0 Content-Type: text/html; charset=utf-8 Location: /Post/View/18 Server: Microsoft-IIS/10.0 X-AspNetMvc-Version: 5.2 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Date: Thu, 23 Nov 2017 03:50:45 GMT Content-Length: 130

Object moved

Object moved to here.

Raw data return

polushinmk commented 6 years ago

You can write me an email (address in my profile) with sample data and, if it possible, test user credentials. I see, that you host your WP site on IIS? Have you tried this patch https://github.com/wp-net/WordPressPCL/wiki/HttpResponsePreProcessing#wordpress-on-azure--iss

sonnd9x commented 6 years ago

I sent an email, please check. Issue occur on my localhost