I am trying to append a line of text to an existing entry in Drafts but keep getting an error that I have an invalid URL. It works fine if I have plain text after the "text=" portion of the URL. It fails when I try to use a variable.
My first guess would be this: you can’t have a literal return character in a URL so either remove
%Return% from the end of your variable
theEntry or URL-encode it.
Hmmm. Good to know.
Unfortunately, I took out the %Return% and it is still failing.
it works with plain text. Somehow I am not processing the variable correctly.
Same goes for the pipes (
|) and spaces, suggesting that filtering the variable with "URL encode" will be the quickest way.
Edit to add: And looking at your string, also the
/s in the date and (probably)
: in the time. In fact, it does no harm to always URL encode any variable you want to pass as an argument in an URL action, just in case.
I just checked and the pipe character
| and spaces also need to be URL-encoded. So after you set up your
theEntry variable, insert a
Filter action to perform the URL-encoding.
What Filter function should I use? I tried "Encode HTML Entities." It stopped KM from flagging the openURL command as yellow, but it still failed to execute.
The problem seems to be that the openURL command won't accept a variable after "text="
That is, if I use "text=SomeText" at the end of the callback URL, it appends to the Draft just fine.
But if I first set a variable TheEntry=SomeText and then use text=%Variable%TheEntry% in the callback URL, it won't execute.
Try the Percent Encode for URL filter.
WooHoo! That did it! Thank you so much.
What I thought was a simple exercise for a Sunday morning has turned out to be quite the learning experience. Time well spent.
Good that it works. Must be another example of Parkinson's Law?