From a1902e6f10841a5de983628b0674474993720153 Mon Sep 17 00:00:00 2001 From: thanhtl Date: Fri, 14 Feb 2025 09:28:03 +0700 Subject: [PATCH] Add d.scpt --- d.scpt | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 d.scpt diff --git a/d.scpt b/d.scpt new file mode 100644 index 0000000..0d4b125 --- /dev/null +++ b/d.scpt @@ -0,0 +1,44 @@ +tell application "DEVONthink 3" + set theSelection to the selection + if theSelection is {} then + display alert "No items selected in DEVONthink!" + return + end if + + set theRecord to item 1 of theSelection + set recName to name of theRecord + set recURL to URL of theRecord +end tell + +-- Adjust these to your actual server, table ID, and token +set baseUrl to "http://10.1.135.227:3322/api/table/tblFPQP7cyNhu26lBYC/record?fieldKeyType=name&viewId=viwQzlEAufKhtR2IGta&cellFormat=json" +set bearerToken to "teable_accRB8GmFw6bKM4hkv7_VXqFVeSsobWA1mx4cqoc8akovMV28kyiSKnGIa9i0/s=" + +set authorizationHeader to "Authorization: Bearer " & bearerToken +set acceptHeader to "Accept: application/json" +set contentTypeHeader to "Content-Type: application/json" + +------------------------------------------------------------------------------ +-- Construct the JSON payload with "records" as the top-level key +------------------------------------------------------------------------------ +set jsonBody to "{\"records\":[{\"fields\":{\"Name\":\"" & recName & "\",\"URL\":\"" & recURL & "\"}}]}" + +------------------------------------------------------------------------------ +-- Build the POST command with curl +------------------------------------------------------------------------------ +set curlCommand to "curl -X POST " & quoted form of baseUrl ¬ + & " -H " & quoted form of authorizationHeader ¬ + & " -H " & quoted form of acceptHeader ¬ + & " -H " & quoted form of contentTypeHeader ¬ + & " -d " & quoted form of jsonBody + +------------------------------------------------------------------------------ +-- Execute and display response +------------------------------------------------------------------------------ +try + set response to do shell script curlCommand + display dialog "Response from server: +" & response +on error errMsg + display alert "Error posting to Table" message errMsg +end try