Delete URL with data (and Patch)

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
pink
Posts: 278
Joined: Wed Mar 12, 2014 6:18 pm

Delete URL with data (and Patch)

Post by pink » Fri Jun 14, 2024 5:46 pm

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!
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

pink
Posts: 278
Joined: Wed Mar 12, 2014 6:18 pm

Re: Delete URL with data (and Patch)

Post by pink » Sun Jun 16, 2024 12:59 pm

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"}
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know

mrcoollion
Posts: 736
Joined: Thu Sep 11, 2014 1:49 pm

Re: Delete URL with data (and Patch)

Post by mrcoollion » Tue Jan 21, 2025 2:13 pm

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

mrcoollion
Posts: 736
Joined: Thu Sep 11, 2014 1:49 pm

Re: Delete URL with data (and Patch)

Post by mrcoollion » Sat Jan 25, 2025 3:15 pm

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

Post Reply

Return to “Internet”