I have this Airtable API URL to get the correct parameters for the filterByFormula feature that airtable has:
https://api.airtable.com/v0/appFFDMzaGGAYkZTo/tbla1PSxklT1335Vf?filterByFormula=AND({Rent}%3D’1592’%2C{Location}%3D’Kirkwood’%2C{Year}%3D’2019’)
Whenever I try to run it by postman. It works. But when I copy and paste it the request definition on a service node. It auto-corrects to this :
https://api.airtable.com/v0/appFFDMzaGGAYkZTo/tbla1PSxklT1335Vf?filterByFormula=AND({Rent}=‘1592’,{Location}=‘Kirkwood’,{Year}=‘2019’)
This is the error when testing it.
“statusCode”: 422,
“body”: {
“error”: {
“type”: “INVALID_FILTER_BY_FORMULA”,
“message”: “The formula for filtering records is invalid: Invalid formula. Please check your formula text.”
@txhighrisers
No that won’t work. You can use both context variables and environment variables in script node of javascript editor ( message nodes, etc).
Environment variables are meant for environment level settings. For example you may have a bot that is for development purposes. You may have a different instance of services api you use for development only. Your production bot may need a different url. So the environment variables help you there.
You can use this API in a script node like this
context.prefRent = context.forms.apartmentpref.Price; ;
context.prefLocation = context.forms.apartmentpref.Location;
context.builtYear = context.forms.apartmentpref.Year;
context.url = “https://api.airtable.com/v0/appFFDMzaGGAYkZTo/tbla1PSxklT1335Vf?filterByFormula=AND(Rent=‘{{context.prefRent}}’,Location=‘{{context.prefLocation}}’,Year=‘{{context.builtYear}}’)&maxRecords=5”
and you can use context.url in a service call.