Page 1 of 1
Delete URL with data (and Patch)
Posted: Fri Jun 14, 2024 5:46 pm
by pink
For an API I am working with, data needs to be sent with the delete command. I've been running rumming through documentation and can't seem to find my help. See below as an example.
Code: Select all
curl --request DELETE 'https://api.tabluar.io/v1/public/tabular/xyzzy/data' \
--header 'ApiKey: <YourAPIKey>' \
--header 'Content-Type: application/json' \
--data-raw '{"row_ids": [1]}'
Also, to update records, it uses PATCH, which I'm also having troubles figuring out.
Can someone point me in the right direction for these 2 items?
Thanks!
Re: Delete URL with data (and Patch)
Posted: Sun Jun 16, 2024 12:59 pm
by pink
The command I've been trying to play with is tsNetCustomUploadSync
Code: Select all
put "APIkey: " & pAPIkey & cr into tHeader
put "Content-Type: application/json" after tHeader
set the httpHeaders to tHeader
put tsNetCustomUploadSync(tTableURL, "DELETE", tHeader, tJSON, rOutHeaders, rResult, rBytes) into tResult
I end up with {"statusCode":403,"message":"Not Allowed"}
Re: Delete URL with data (and Patch)
Posted: Tue Jan 21, 2025 2:13 pm
by mrcoollion
Hi pink,
I could not get the DELETE request via tsNetCustomSync working , however mayby in your case it works because I get a server error which could not be a code issue.
For more information on the tsNet functionality see:
https://www.techstrategies.com.au/tsnet-command-list/
I have the following code.
Code: Select all
put "http://localhost:3001/api/v1/system/remove-documents" into tURLString
------------------------------------------------
put tDocumentName into aSettings["names"] // Want to delete a document
put "DELETE" into tRequest
------------------------------------------------
-- Prepare headers, in Headers do not use crlf but use lf
put "Content-Type: application/json" & lf & \
"accept: application/json" & lf & \
"Authorization: Bearer " & tApiKey into tHeaders
------------------------------------------------------------------
put tHeaders into tPrePostHeaders // Just for keeping track
------------------------------------------------------------------
# Make the API call using TSNet
put "" into field "InfoWindow" // empty field first
tsNetSetDebugCallback("updateDebugField") // For Debugging
tsNetInit
put tsNetCustomSync(tURLString, tRequest, tHeaders, tRecvHeaders, tResult, tBytes,aSettings) into tData
tsNetClose
The debug function is below and it puts the debug information into a field.
Code: Select all
on updateDebugField pConnId, pMessage
put pConnId & ":" && pMessage after field "InfoWindow"
put the formattedHeight of field "responseField" into tScroll
set the vScroll of field "responseField" to tScroll
end updateDebugField
Regards,
Paul
Re: Delete URL with data (and Patch)
Posted: Sat Jan 25, 2025 3:15 pm
by mrcoollion
I solved it with a shell command so I could use the original curl command.
See my post.
https://www.forums.livecode.com/viewtop ... =9&t=39560
Regards,
Paul