Feb 23, 2021 06:44 AM
I just can’t find the right way to format my request. I’m trying to update a single field in a single record. but keep hitting - INVALID_REQUEST_MISSING_FIELDS",“message”:"Could not find field “fields” in the request body
Getting data is fine.
After a few hours trying different things I’m asking for help what am I missing? Any help appreciated
API and Base ID Blanked out
function apiCall(){
var API_KEY = ‘XXXXXXXXX’;
var root = ‘https://api.airtable.com/v0’;
var baseId = ‘XXXXXXXXXXXX’;
var tableName = encodeURIComponent(‘Travels’);
var recordId = “recSaJTXSBu1g8CBd”
var endpoint = ‘/’ + baseId + ‘/’ + tableName + ‘/’ + recordId;
var params = {
‘method’: ‘PATCH’,
‘muteHttpExceptions’: true,
‘Content-Type’: ‘application/json’,
‘headers’: {
‘Authorization’: 'Bearer ’ + API_KEY
},
"fields" : {
"Declaration link": "https://docs.google.com/spreadsheets/d/13V8gO7511yJ0830IpiKXtfYfKeuVVSJ8uqbXR-9Ne8w/edit#gid=0"
}
};
var response = UrlFetchApp.fetch(root + endpoint, params);
Logger.log(response.getContentText());
}
Solved! Go to Solution.
Feb 23, 2021 07:54 AM
Thanks Bill , I did have the record id but the code is not super readable on the forum. Also I had tried with the payload also but I was getting the same error. But your code helped me see what I think was the mistake. The content type was stored outside of the headers in my params.
for others working code below.
Feb 23, 2021 07:27 AM
I think you have at least two issues:
Feb 23, 2021 07:54 AM
Thanks Bill , I did have the record id but the code is not super readable on the forum. Also I had tried with the payload also but I was getting the same error. But your code helped me see what I think was the mistake. The content type was stored outside of the headers in my params.
for others working code below.
Feb 23, 2021 09:17 AM
Use the preformatted text styler in the editor toolbar to format the code for easier reading. For multi-line code snippets, wrap the code in pairs of graves triplets → ```
Example:
```
// This is some code
let something = “Something”;
```
…becomes…
// This is some code
let something = "Something";