Nov 19, 2024 03:59 AM - edited Nov 19, 2024 04:02 AM
Hi all
I've been working on SAP Integration Suite for connecting to airtable and perform CRUD operations. I've created a integration flow for PATCH request in my suite and wanted to test it through POSTMAN by hitting the endpoint of PATCH iflow. The issue here is that even though i'm sending my json payload in the format of airtable PATCH request postman is throwing 500 error.
My table in airtable
Note that EmpID is also Single Line Text here
Below are my configurations of the integration flow i've created to perform a PATCH operation through POSTMAN.
Json payload i'm sending through postman to suite
In Https adapater
Added a groovy script after start for fetching the airtable id through the json payload
Added Content modifier to update headers with bearer token, Content-Type and Accept (hardcoded bearer token in header itself as of now for testing. Will change it to dynamic value later)
Under exchange property i've added id to send it to the endpoint and body for checking the payload being sent.
The response of id and body that are going to be sent before i've got before adding request reply.
The HTTP adapter configurations are
Postman request
When i've checked the message monitoring my airtable ID is getting attached to the airtable PATCH endpoint but it shows the below error.
To double check whether i'm passing the correct ID i've even sent a get request and ensured that correct ID is being sent
Solved! Go to Solution.
Nov 19, 2024 09:26 AM
There are two ways of updating a record via the API. Your request seems to be a bit of a mashup of the two different methods.
One method is to update a single record at a time by accessing the endpoint/url for the single record. In this situation, the record ID is in the endpoint/url and not in the payload.
The other method is to update the a batch of records but include only one record in the array. In this situation, you use the endpoint of the table (not the record), and the body is shaped as Adam described in his post.
Other things to check:
- Does your personal access token have access to the base with the proper scope?
- Does the table or any fields have any permission limitations preventing the user from making edits?
You might also want to try accessing the API via a plain JavaScript fetch request, instead of Postman. It is relatively easy to do using Airtable scripting extension. To protect your personal access token you can use it in a new base that only you have access to and then delete the base afterwards.
Nov 19, 2024 04:37 AM
Could I confirm that you managed to get a PATCH request to Airtable directly working? I didn't see a screenshot of a working PATCH request to Airtable but could have missed it, sorry!
Here's an example of the body of a PATCH request that updates multiple records if that helps:
{
"records": [
{
"id": "recGlyHdHCHOMPwzK",
"fields": {
"URL": "www.google.com"
}
}
]
}
Nov 19, 2024 05:06 AM - edited Nov 19, 2024 05:08 AM
Your code is not in the proper format that Airtable is expecting.
To make this easy for you, Airtable has created an interactive customized API guide that actually uses real data from your real base, and generates real code for you based on your real fields and real data.
You can get to this interactive customized guide by going to this Airtable REST API page, then scrolling down on the page and choosing the base that you want to work with.
Hope this helps! If you’d like to hire an expert Airtable consultant to help you with anything Airtable-related, please feel free to contact me through my website: Airtable consultant — ScottWorld
Nov 19, 2024 09:26 AM
There are two ways of updating a record via the API. Your request seems to be a bit of a mashup of the two different methods.
One method is to update a single record at a time by accessing the endpoint/url for the single record. In this situation, the record ID is in the endpoint/url and not in the payload.
The other method is to update the a batch of records but include only one record in the array. In this situation, you use the endpoint of the table (not the record), and the body is shaped as Adam described in his post.
Other things to check:
- Does your personal access token have access to the base with the proper scope?
- Does the table or any fields have any permission limitations preventing the user from making edits?
You might also want to try accessing the API via a plain JavaScript fetch request, instead of Postman. It is relatively easy to do using Airtable scripting extension. To protect your personal access token you can use it in a new base that only you have access to and then delete the base afterwards.
Nov 19, 2024 08:33 PM
HI @kuovonne thank you so much for this one...after checking the solution of @TheTimeSavingCo for multiple record updation i didn't understand how to perform that and after your clarification on the solution for setting table as endpoint it worked as charm for my single record...Thank you!!
Nov 19, 2024 08:35 PM
Thank you @TheTimeSavingCo ...idea of multiple record updation worked for me..Thank you so much once again😊
Nov 19, 2024 08:37 PM
Thank you @ScottWorld for letting me know that airtable exclusively takes our base and gives the documentation for it...i've actually taken the code from the documentation and made my changes..Thank you😊