A few weeks back I posted some details of working with passing dictionary data between Shortcuts and Scriptable in response to a query. One of these methods was around the use of x-callback-url. Take a look at the CarLog3 script in the following linked post, and have a read through the details of the third method.
So I’m stuck here. What I want is actually super simple. I want to just pull in text from Drafts to Scriptable. The ultimate goal is to use that text in a widget. I can’t get that data in at all. What am I doing wrong?
The URL scheme I’m using is:
The Scriptable lines I’m using are:
const successURL = args.queryParameters[“x-success”];
I did try to use cpac’s Drafts code but I don’t get what’s going on in the Drafts section of the script.
Do remember to block your code with back ticks, otherwise we have to amend the code to remove all the stuff that Discourse does to it when you post.
Drafts’ call to get doesn’t return x-success. x-success is the URL for Drafts to run on a successful x-callback run. get appends the (URL encoded) draft text to the x-success URL as a parameter called text.
When the Scriptable script runs, we do want to access args.queryParameters, but the result isn’t an array. It’s actually an object with the attributes of the parameters.
Finally, you probably also want to make the draft content the message rather than the title of the alert.
Maybe try it more like this:
let alert = new Alert()
alert.message = args.queryParameters.text;
alert.title = "Draft Content"
Thanks so much for taking the time with this. That was helpful. I wish I could swing this project—displaying some text from either Drafts or even just from Shortcuts in a Scriptable widget. I’m afraid my skills just aren’t up to it and I can’t find enough Scriptable documentation to work it out. After maybe 10+ hours, learning curve has me beat, I’m afraid.