Skip to content

Error on CreateAsync  #340

@oesquedac

Description

@oesquedac

Hi, i cant create a post using the version 2.0.1

This is the Code:

    var client = new WordPressClient( "http://sitioweb.com/wp-json/" );
    client.Auth.UseBasicAuth( "username", "app_password" );        

    var post = new Post() {
      Title = new Title( "ITCmx" ),
      Content = new Content( "Content PostCreate" )
    };

    var createdPost = await client.Posts.CreateAsync( post );

And get this error

Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'WordPressPCL.Models.Post' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path '', line 1, position 1.

I try on Postman and works fine

Could you please help me

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions