Skip to main content

Curl with PHP doesn't update record


Mi update with curl doesn’t work and i dont know where is the error

Record id, url and key are corrects (they works with delete and create rows), but not with update.
¿Can someone help me?
Thanks for your time!

14 replies

Okeowo_Aderemi
Forum|alt.badge.img+1
  • Participating Frequently
  • 9 replies
  • May 27, 2022

Hi did you also test this out on Postman first to be sure there isn’t any issue with the endpoint, also what response did you get ?


  • Author
  • Participating Frequently
  • 7 replies
  • May 27, 2022
Okeowo_Aderemi wrote:

Hi did you also test this out on Postman first to be sure there isn’t any issue with the endpoint, also what response did you get ?


I dont know if im doing good on Postman, is this correct or im doing something wrong?


Okeowo_Aderemi
Forum|alt.badge.img+1
  • Participating Frequently
  • 9 replies
  • May 27, 2022
Albert_Muela_Do wrote:

I dont know if im doing good on Postman, is this correct or im doing something wrong?


Did you send the X-Airtable-Client-Secret in the header ?


  • Author
  • Participating Frequently
  • 7 replies
  • May 27, 2022
Okeowo_Aderemi wrote:

Did you send the X-Airtable-Client-Secret in the header ?


This is mi header, i need something more here?


Okeowo_Aderemi
Forum|alt.badge.img+1
  • Participating Frequently
  • 9 replies
  • May 27, 2022
Albert_Muela_Do wrote:

This is mi header, i need something more here?



  • Author
  • Participating Frequently
  • 7 replies
  • May 27, 2022

Why i didn’t use it in create record or delete record and they works? I only need on update?


kuovonne
Forum|alt.badge.img+27
  • Brainy
  • 6002 replies
  • May 27, 2022

Welcome to the Airtable community!

To do an update you need a PATCH request. It looks like you are setting your custom request to PATH. Try adding the C.


  • Author
  • Participating Frequently
  • 7 replies
  • May 28, 2022
kuovonne wrote:

Welcome to the Airtable community!

To do an update you need a PATCH request. It looks like you are setting your custom request to PATH. Try adding the C.


Ops! That’s true, i add “C” but still doesnt work

Is param’s array correct?


kuovonne
Forum|alt.badge.img+27
  • Brainy
  • 6002 replies
  • May 28, 2022
Albert_Muela_Do wrote:

Ops! That’s true, i add “C” but still doesnt work

Is param’s array correct?


Are you getting an error message? If so what?

Are your $params correct?
Are you updating one record, or multiple records?
If yo are updating only one record, are you using the endpoint for the record or the endpoint for the table?
If you are using the endpoint for the table, it looks like your body is missing the records key as described in the API documentation.


  • Author
  • Participating Frequently
  • 7 replies
  • May 29, 2022
kuovonne wrote:

Are you getting an error message? If so what?

Are your $params correct?
Are you updating one record, or multiple records?
If yo are updating only one record, are you using the endpoint for the record or the endpoint for the table?
If you are using the endpoint for the table, it looks like your body is missing the records key as described in the API documentation.


Mi params are correct: $field → Column name, $value → boolean (is check column)
Im updating only one record.
Im using table endpoint (that works on delete and insert statements)
The record’s key is in $record[‘id’] in $params, i not sure about that, for that i asked for mi param’s array.


  • Author
  • Participating Frequently
  • 7 replies
  • May 29, 2022
kuovonne wrote:

Are you getting an error message? If so what?

Are your $params correct?
Are you updating one record, or multiple records?
If yo are updating only one record, are you using the endpoint for the record or the endpoint for the table?
If you are using the endpoint for the table, it looks like your body is missing the records key as described in the API documentation.


This is mi create record

And this, si mi delete record:

They works fine, i dont know why mu update doesn’t, only the param’s array is the difference…


kuovonne
Forum|alt.badge.img+27
  • Brainy
  • 6002 replies
  • May 30, 2022
kuovonne wrote:

Are you getting an error message? If so what?

Are your $params correct?
Are you updating one record, or multiple records?
If yo are updating only one record, are you using the endpoint for the record or the endpoint for the table?
If you are using the endpoint for the table, it looks like your body is missing the records key as described in the API documentation.


The top level object in the body should have a key of “records” whose value is the array of records. This key is at the same level as the “typecast” key.


  • Author
  • Participating Frequently
  • 7 replies
  • May 31, 2022
kuovonne wrote:

The top level object in the body should have a key of “records” whose value is the array of records. This key is at the same level as the “typecast” key.


Finally it works, the array was the problem. If i use this, all go fine:

Thanks all for your time and help!


kuovonne
Forum|alt.badge.img+27
  • Brainy
  • 6002 replies
  • May 31, 2022
Albert_Muela_Do wrote:

Finally it works, the array was the problem. If i use this, all go fine:

Thanks all for your time and help!


Glad you got it working.

Is there a reason why you switched to doing the JSON encoding manually? That step is unrelated to including the top level “records” object key, which was your main problem. Depending on the names and values of your fields, you may eventually get values that will be very difficult to encode manually.


Reply