45 lines
1.8 KiB
AppleScript
45 lines
1.8 KiB
AppleScript
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
|