URL tag POST data not working
I cannot get the URL tag working with post data. Any ideas?
I got the SCRIPT tag working with post data.
- Open Quicktext Settings
- Templates > Add group > Title: MyGroup
- Templates > Add templates > Title: MyTemplate
[[SCRIPT=MyScript]]
Insert as: HTML
- Scripts > Add script > Title: MyScript
function makeRequest() {
return new Promise(function (resolve) {
var xhr = new XMLHttpRequest();
xhr.open("POST", "http://www.dsl-mud.org/algoron/equipment/keyword_items.asp", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onload = function () {
if (xhr.status == 200) {
resolve(xhr.responseText);
}
};
xhr.send("keyword=leather%20bracer");
});
}
this.compose.setComposeDetails({
body: '<body style="background-color:black;"></body>',
});
return await makeRequest();
POST example - type leather bracer in box and click button http://www.dsl-mud.org/algoron/equipment.asp http://www.dsl-mud.org/algoron/equipment/keyword_items.asp
Quicktext wiki - URL tag http://github.com/jobisoft/quicktext/wiki/List-of-all-supported-tags#url
Quicktext 6.4 Thunderbird ESR 140.4.0 Windows 10 Pro 22H2 32-bit
Okay. I got the URL tag working with post data.
I hacked the quicktextParser.mjs file as a test.
let postdata = method == "post"
? post.map(encodeURIComponent).join("&")
: null;
+ console.log("debug method:", method);
+ console.log("debug post:", post);
+ console.log("debug postdata:", postdata);
req.send(postdata);
I typed the "alpha beta" string in the subject textbox, then used the following URL tag.
[[URL=http://httpbin.org/post|subject]]
debug method: post debug post: Array [ "subject=alpha beta" ] debug postdata: subject%3Dalpha%20beta
I copied the "alpha beta" string to the current clipboard, then used the following URL tag.
[[URL=http://httpbin.org/post|clipboard]]
debug method: post debug post: Array [ "clipboard=[object Object]" ] debug postdata: clipboard%3D%5Bobject%20Object%5D
I guess [object Object] in the post array is a bug.
The CLIPBOARD tag works correctly. It gets the "alpha beta" string, not the "[object Object]" string.
[[CLIPBOARD]]
HTTPBin (useful tool for testing) http://httpbin.org/ http://kennethreitz.org/software/websites/httpbin
Is clipboard the only POST property which fails the URL tag? Can you check if it is fixed for you if you apply this fix to your local copy?
https://github.com/jobisoft/quicktext/commit/cc4cc6e03aa767d0e923a44d5acdf02d614a90f4
I added your fix to my local copy. That works fine with the clipboard POST property. The other POST properties work correctly with the URL tag, but you are missing the selection POST property in the documentation.
Specifies what values are POSTed to the url: att, clipboard, counter, date, from, orgatt, orgheader, subject, time, to, version.
Quicktext wiki - URL tag http://github.com/jobisoft/quicktext/wiki/List-of-all-supported-tags#url
Thanks.