Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    You should be able to use an array or a string to define tags or categories to use in a request.

    If that doesn’t help, could you send us an email with the code you used, so we can take a closer look?
    http://developer.wordpress.com/contact

    Thanks!

    Thread Starter dleeward

    (@dleeward)

    I understand that, but I’m not a developer and don’t know the format the array needs to be in. Can you give me an example?

    Plugin Author Jeremy Herve

    (@jeherve)

    Jetpack Mechanic 🚀

    You can check the examples at the bottom of the documentation:
    https://developer.wordpress.com/docs/api/1/post/sites/%24site/posts/new/

    As you can see, it includes a part where you define the request parameters. The example uses strings:

    array (
        'title' => 'Hello World',
        'content' => 'Hello. I am a test post. I was created by the API',
        'tags' => 'tests',
        'categories' => 'API',
    )

    You can use arrays instead, like so:

    array (
        'title' => 'Hello World',
        'content' => 'Hello. I am a test post. I was created by the API',
        'tags' => array( 'tests', 'other', 'tag2', 'tag1' ),
        'categories' => array( 'API', 'category2' )
    )
    Thread Starter dleeward

    (@dleeward)

    I received this answer to my question from Andrew at WordPress.com support:

    An example using HTTP array:

    title=Test&tags[]=onetag&tags[]=twotag

    … a new post will be created with two tags: “onetag” and “twotag”. Note that this is supported for the post creation endpoint as a convenience, and other endpoints may only accept the array syntax. Be sure to refer to the documentation for the specific endpoint to be sure.

    Hope it helps someone else as well.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Array format missing in API REST API documentation’ is closed to new replies.