Help

Invalid request: parameter validation failed. Check your request data.

Topic Labels: API Scripting
Solved
Jump to Solution
3831 1
cancel
Showing results for 
Search instead for 
Did you mean: 
adamshand
4 - Data Explorer
4 - Data Explorer

Hello,

I'm a new to the AirTable API and trying to automate adding records with data from another API.  I have this function:

	async function updateCrewRecords(data: CrewDetailsType[]) {
		const crewBase = new Airtable({ apiKey: AT_API_KEY }).base('appxxx')
		const table = cewBase('tblxxx')

		const records = data.map((crew) => ({
			fields: {
				CrewID: crew.CrewID,
				CompanyID: crew.CompanyID,
				IsActive: crew.IsActive,
				Position: crew.Position,
			},
		}))

		try {
			// const response = await table.create(records, { typecast: true })
			const response = await table.update(records, {
				typecast: true,
				performUpsert: true,
				fieldsToMergeOn: ['CrewID'],
			})
		} catch (e: any) {
			const errorMsg = `updateCrewRecords(): ${e.message}`
			console.log(e.statusCode, errorMsg)
			// throw error(e.statusCode, e.message)
		}
	}

 The commented out table.create(records) works as expected, but the upsert doesn't.  The error I'm getting is:

422 updateCrewRecords(): Invalid request: parameter validation failed. Check your request data. 

I can't find any way to get any more specific information on what is going wrong.

Any help would be much appreciated!
Thanks,
Adam.

1 Solution

Accepted Solutions
adamshand
4 - Data Explorer
4 - Data Explorer

<grr> finally ask for help and then figure it out. 🙄

This works. 😮💨

const response = await table.update(records, {
	typecast: true,
	performUpsert: {
		fieldsToMergeOn: ['CrewID'],
	},
})

See Solution in Thread

1 Reply 1
adamshand
4 - Data Explorer
4 - Data Explorer

<grr> finally ask for help and then figure it out. 🙄

This works. 😮💨

const response = await table.update(records, {
	typecast: true,
	performUpsert: {
		fieldsToMergeOn: ['CrewID'],
	},
})