PATCH problems with API -- "'fields' is required"

Hey all,
Has anyone experienced trouble with API calls to PATCH with an error “‘fields’ is required”? I can successfully make GET and DELETE calls (using Postman) but haven’t succeed in any of the proactive calls like PATCH, PUT or POST. I am trying to troubleshoot in Postman to ultimately use a Zapier Webhook to PATCH a reference field in the CMS.

The error I receive is “‘fields’ is required”. The API token, Content-Type and accept-version are all fine. The field ID I am trying to patch is also fine (I double-checked it using a GET call to the API). Has anyone had this hurdle and overcome it?

https://api.webflow.com/collections/MYCOLLECTION/items/MYITEM?live=true

{
“fields”: {
“last-name”: “Fiftyone”,
}
}

Thanks,
Tim

Hey @tim28, I haven’t tried this but I believe I see a syntax error in your JSON. Remove the comma after “Fiftyone” and give it another shot?

1 Like

I wanna cry. It worked! :slight_smile: :slight_smile: I swear I tried it in the past with and without a comma and it made no difference, but this time it worked. Thanks so much Sam!

1 Like

Sometimes the simplest solutions are the most satisfying ones!

1 Like

Definitely Andy!! :man_facepalming:
Now just trying to figure out the right way to PATCH a field that is a CMS reference field.
The error message (when I try to use the actual “name” of the record I’m referencing) is:
“Expected value to be an ItemRef”

@tim28 have you tried using the CMS Item ID instead of the name?

Here’s an example of one I’m using.

Incredible, Andy, thank you!! It works. Been stewing about this for over a week. So relieved! Taking a breath and will now try and reorganize the AirTable fields and zaps to work with this new Item ID organization. Thanks again :blush:

1 Like

@tim28 awesome! It does also work with multiple items at once, but it can be a bit fussy about the format. I use a Rollup column in Airtable to enable this, but it depends on your needs.

Glad it helped!

@Andy_Vaughan exactly, you got me over a huge hurdle by explaining that the CMS reference patch must be to the Webflow item ID. Now I’m at the point where Postman is working for this API call, but when I try to run it in Webhooks by Zapier, it doesn’t work. The error message is:
The app returned “Invalid access token provided.”.
Does anything leap out at you?

@tim28 note the use of square brackets in my example - give that a go and see if it works. Nothing else is jumping out at me.

Thanks @Andy_Vaughan it was a good try but the square brackets didn’t change it – still the ‘invalid access token provided’ message from Webhooks by Zapier.

@tim28 weird. I’ll have to have another look tomorrow when I’m on the PC I’m afraid (UK time here) as I’m on my phone right now, and I can’t pretend that I’m an expert on this topic unfortunately.

1 Like

@tim28 I’ve just done some playing in Zapier, and the only way I can replicate the same error code that you are getting is by making a mistake in the “Authorization: Bearer” section.

One thing I noticed is that it’s easy to end up with a superfluous space between “Bearer” and your API key. I found that adding a space between the two didn’t actually move the text at all - Bearer Key looks identical to BearerKey. It will not work if there is a space between the two. Give that a go and see if that works for you.

@Andy_Vaughan because you were kind enough to test what I had done, you identified the problem and solved my week-long headache. The problem was indeed between Bearer and the key…I found that it does need a single space, but not a linebreak!
In other words,

Bearer XXXXXXXXXX

NOT

Bearer
XXXXXXXXXXX

These do look the same on the Webhooks by Zapier console, since Zapier adds a natural linebreak when you enter a space.

So, to sum up this thread thanks to @Andy_Vaughan and @sam-g, I learned that:

  1. JSON data entries cannot have an extra comma, if there is no additional data following.
    CORRECT EXAMPLE:
    {
    “fields”: {
    “appointment-type”: “studio”
    }
    }

INCORRECT EXAMPLE:
{
“fields”: {
“appointment-type”: “studio”,
}
}

  1. Patching Webflow CMS reference fields (it doesn’t matter if they are single reference or multi-reference) must be done using the Webflow item ID, not the Webflow name or slug.

  2. Authorization in Webhooks by Zapier must strictly follow:
    Bearer XXXXXXXXXX

NOT
Bearer
XXXXXXXXX

Thanks again, @Andy_Vaughan and @sam-g. :raised_hands: :zap:

1 Like

No worries @tim28, glad we got there! I’ll be bookmarking this thread for future reference when I inevitably forget how to do this :joy:

@Andy_Vaughan lol absolutely, I’ve let Zapier know about it too.

Hi Guys. I’m having the same issue with the API validation. I have tried with and without spaces @tim28 can you confirm whether you were using around your api key and how you made sure t didn’t have a linebreak?

Please anyone can help i am really stuck in this … i checked there was no extra space after Bearer as well

@Andy_Vaughan @tim28

1 Like

I’m having the same issue as the people above @Andy_Vaughan @tim28