Help formatting JSON or Query Parameters for Wordpress API

Hi,

I’m trying to sent a POST request with the HTTP request node, to the Wordpress API. Specifically, I can’t figure out how to format the JSON for the post meta data.

If I send a GET request, this is the JSON I get:

[
  {
    "id": 998,
    "date": "2022-12-02T18:44:08",
    "date_gmt": "2022-12-03T02:44:08",
    "guid": {
      "rendered": "https://www.mysite.com/?post_type=my-post-type&p=998"
    },
    "modified": "2022-12-02T18:44:08",
    "modified_gmt": "2022-12-03T02:44:08",
    "slug": "",
    "status": "draft",
    "type": "my-post-type",
    "link": "https://www.mysite.com/?post_type=my-post-type&p=998",
    "title": {
      "rendered": "New Launch"
    },
    "content": {
      "rendered": "<p>The content.</p>",
      "protected": false
    },
    "excerpt": {
      "rendered": "<p>The content.</p>",
      "protected": false
    },
    "author": 1,
    "featured_media": 0,
    "comment_status": "closed",
    "ping_status": "closed",
    "template": "",
    "meta": {
      "homepage": "",
      "twitter": "",
      "discord": "",
      "twitter-followers-jet": "",
      "discord-members-jet": "",
      "discord-online-jet": ""
    },
    "post_type_category": [],
    "post_type_tag": [],
    "uagb_featured_image_src": {
      "full": false,
      "thumbnail": false,
      "medium": false,
      "medium_large": false,
      "large": false,
      "thumblist": false,
      "meccarouselthumb": false,
      "gridsquare": false,
      "tileview": false,
      "1536x1536": false,
      "2048x2048": false
    },
    "uagb_author_info": {
      "display_name": "Author Name",
      "author_link": "https://www.mysite.com/author/author-name/"
    },
    "uagb_comment_info": 0,
    "uagb_excerpt": "The content.",
    "_links": {
      "self": [
        {
          "href": "https://www.mysite.com/wp-json/wp/v2/my-post-type/998"
        }
      ],
      "collection": [
        {
          "href": "https://www.mysite.com/wp-json/wp/v2/my-post-type"
        }
      ],
      "about": [
        {
          "href": "https://www.mysite.com/wp-json/wp/v2/types/my-post-type"
        }
      ],
      "author": [
        {
          "embeddable": true,
          "href": "https://www.mysite.com/wp-json/wp/v2/users/1"
        }
      ],
      "replies": [
        {
          "embeddable": true,
          "href": "https://www.mysite.com/wp-json/wp/v2/comments?post=998"
        }
      ],
      "version-history": [
        {
          "count": 1,
          "href": "https://www.mysite.com/wp-json/wp/v2/my-post-type/998/revisions"
        }
      ],
      "predecessor-version": [
        {
          "id": 61421,
          "href": "https://www.mysite.com/wp-json/wp/v2/my-post-type/998/revisions/61421"
        }
      ],
      "wp:attachment": [
        {
          "href": "https://www.mysite.com/wp-json/wp/v2/media?parent=998"
        }
      ],
      "wp:term": [
        {
          "taxonomy": "my-post-type_category",
          "embeddable": true,
          "href": "https://www.mysite.com/wp-json/wp/v2/mec_category?post=998"
        },
        {
          "taxonomy": "my-post-type_tag",
          "embeddable": true,
          "href": "https://www.mysite.com/wp-json/wp/v2/mec_tag?post=998"
        }
      ],
      "curies": [
        {
          "name": "wp",
          "href": "https://api.w.org/{rel}",
          "templated": true
        }
      ]
    }
  }
]

I am able to post/edit to the top level items, like “title,” like this:

But I don’t understand what to put in the query parameters to make it change something in a second level, like the meta → homepage.

I’ve tried a bunch of things but am not getting it right, if anyone can give me a hint it would be greatly appreciated!

Hi @mmac, I am not very familiar with the Wordpress API, but you can send nested JSON like this in the HTTP Request node:

What I am using here is an expression returning a valid JSON object:

image

This example request arrives like so on the web server:

image

This would be for the request body though, as I am not aware of how nesting through query parameters could work. Perhaps you have a working curl request for the change you are struggling with?

Th HTTP request example didn’t work, but using the format of the raw content did. Not sure why it’d be different, but I have it working now. Thank you!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.