I'm attempting to create a record, pass a variable, and open that record in Airtable. Where I'm running into issues is passing the variable to the record and then grabbing the record id after the response. I've read the using Keyboard Maestro variables section in this link but still can't seem to pass the variable. It just passes $KMVAR_Title, instead of what's in the variable and I also can't figure out how to grab a certain dictionary value from the response after the post, mainly the id: value.
I've posted the macro, script, and response below.
Most likely it is because the "$KMVAR_Title" is also between single-quotes, which will prevent all Bash variables, include KM Variables, from expanding.
You can try changing the syntax in the Execute Shell Script, but I'd suggest that you compose the entire command in a KM Variable, and then just pass that Variable to the Shell Script.
When you are using a KM Action to set a variable, you don't have to worry about quotes, single or double. You can reference a KM Variable by simply using the variable token, as in: "Title": "%Variable%Title%",
That makes sense but for some reason it still won't work. I changed echo to curl in your example and entered the API key but it would not post nor give me a response.
I don't think it's because the variable is not expanding because does display with results with echo but after I change it to curl it doesn't do anything.
Because splitting and variable interpolation and de-quoting happens at the same time - and so any quotes within a variable are meaningless.
For example:
% ls "a b" "c d"
ls: a b: No such file or directory
ls: c d: No such file or directory
The parameters to ls are:
ls
a b
c d
Where as:
% v='ls "a b" "c d"'
% echo $v
ls "a b" "c d"
% $v
ls: "a: No such file or directory
ls: "c: No such file or directory
ls: b": No such file or directory
ls: d": No such file or directory
Not what you want.
You can use eval:
% eval $v
ls: a b: No such file or directory
ls: c d: No such file or directory
But honestly, I don’t really understand what eval does so I don’t know why it works.