This one's probably too deep for me for me to assist with. But I'll ask a question. I don't understand where you are invoking the KM engine here to replace the KM variables and tokens. It doesn't seem that you are implying that this script is placed inside a script action in KM. If not, how where are you expecting the KM Engine to kick in? You make no mention of executing any KM action, so I'm not sure why you think that KM could respond by replacing these variables and tokens.
Remember, I'm just an average guy here. There are much smarter people here than me, so if you want to wait for them, I understand.
I’ve set up KM to copy the subject of the email and email url into two variables; SubVar and EmlVar.
What I’m failing to achieve is getting the expanded variables into the Curl command and executing the Curl command. The command runs correctly in the execute script command, but I’m having a hard time getting the variables to expand.
I can get them to expand if I save both variables as another variable. But I then cannot get that variable to run in the execute script command. I can get it to save as text, just not into the execute variable.
Okay, now that you stated that you are running the script in an Execute Shell Script action, maybe I can help.
Because the way you are writing the command is not how variables are expanded in that action. To expand a variable in an action the syntax is: $KMVAR_varname
Perhaps if you show your action in an image then I can be sure that I'm giving you the right advice. I'm still scared that I might be giving bad advice because I'm not sure where you are executing that script.
Upon further reflection I think there's a chance you might fix this if you replace the above with this:
However I'm only 70% sure this will fix your issue because I'm only 70% sure that you are using this code in an Execute Shell Script action. And also because I don't usually use variables the way you do in unix scripts.
Whenever I have a problem like this, what I do is find a way to see what's being passed to the command. The command you are using is curl. You are passing a string with some variables. We can't see what that string is. So I think the first easy step is to replace the word curl with echo and see what is displayed then. After the curl command you have four lines of text separated by backslashes to break the command into multiple lines. Since I'm not sure if echo works with backslashes (I think it does), you may want to combine them into a single line. Do that if you wish.
Once you see what the result is, I would then open a Terminal window and manually enter curl then place the output from the window that appeared after the word curl. Do you see my reason for doing this? It's to validate what's being passed too curl.
P.S. I had never heard of Dynalist until now, and I haven't use curl too often, so my advice is just coming from the perspective of an average KM user. But I think the odds are good that we can figure this out. I just came back from lunch so I'm around now.
Thanks gglick. I didn't think of that either. It was just yesterday that I had to write a bit of code because I didn't know how to remove a trailing CR from a variable. I never thought of CRs as white space.