CMS API and Zapier

Hi @michael,

I’m no expert but I have a little experience with custom zaps. First, see my explanation in this thread above:

Second, get yourself a copy of Postman – it’s a free web app that lets you test and try out API calls. Really handy! It gives good error messages that Zapier doesn’t and when you get it working there, you can just copy & paste into Zapier.

Third, I went into some more detail about custom zaps over in this thread, with screenshots, which you may find helpful also!

Now, for your questions:

  1. Yes, if you’re updating / PUTing an item, you need to send along the item you want to update. To get all the items (with IDs) for a collection, see this page in the API docs. You can use cURL or Postman to send the data payload and get a response.
  2. Yes, JSON is right!
  3. For the format in data field, I’m pretty sure you don’t need the “fields_” prefix, but I’m happy to be corrected! I’ve only used “custom data” zap, where you can just copy/paste your own JSON, and the format goes like this:
    { "fields": { "name": "Exciting blog post title", "slug": "exciting-post", "_archived": false, "_draft": false, "color": "#a98080", "author": "580e640c8c9a982ac9b8b778", "post-body": "<p>Blog post contents...</p>", "post-summary": "Summary of exciting blog post", } }
    Basically, make sure you wrap the “fields” object in another object.
  4. I’m not totally sure which ones are required – you can run tests in Postman and it will tell you if you missed a required one. I know that if you don’t specify “draft” and “archived”, it’ll just assume some defaults. So maybe just “name”? I think “slug” is also defaulted for you.
  5. Header is not correct for “Authorization”. It should read:
    Bearer 12341351341535351351
    where the <token> after Bearer is the API key for that specific, individual site. You can generate the API token in the settings panel explained here, then just copy / paste.

Try that and let me know if you get it to work!

4 Likes