wp-net / WordPressPCL

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

"Cannot create existing posts" on an empty Wordpress #251

Closed unnanego closed 3 years ago

unnanego commented 3 years ago

I've created a brand new installation with latest stable nginx and php 7.4, latest wordpress version, installed the recommended JWT plugin for authentication.

I'm getting a post from my old blog and trying to create it (move it) on the new one, but I'm always getting the "cannot create existing post" exception, when the database is empty and there are no posts in any way - can't query or delete, it's not showing up anywhere. If I change the site language to Russian, the message also comes in Russian, so I'm guessing it's the wordpress problem?

I've tried creating an empty post - works this way.

hinnerkweiler commented 3 years ago

Just a guess: when creating a post the ID must not be set. The ID can only be set by Wordpress at the time of post creation in the Database. So you can not keep it when cloning your content. Remove the ID (set it to 0) before handing it to the new blog. If an ID is given, WP will try to alter a post by that ID and since it is not there yet it returns this not too helpful message.

ThomasPe commented 3 years ago

@unnanego I take it this solved your issue?

unnanego commented 3 years ago

Yes!