(PureBasic) HTTP DELETE with Body
Demonstrates how to send a DELETE request with a body.
IncludeFile "CkHttpResponse.pb"
IncludeFile "CkHttp.pb"
Procedure ChilkatExample()
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
http.i = CkHttp::ckCreate()
If http.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Use the PText method (or PTextSb) to send a DELETE request with a body.
requestBody.s = "{ " + Chr(34) + "abc" + Chr(34) + ": 123 }"
resp.i = CkHttp::ckPText(http,"DELETE","https://example.com/something",requestBody,"utf-8","application/json",0,0)
If CkHttp::ckLastMethodSuccess(http) = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
ProcedureReturn
EndIf
Debug "Response status: " + Str(CkHttpResponse::ckStatusCode(resp))
Debug "Response body: "
Debug CkHttpResponse::ckBodyStr(resp)
CkHttpResponse::ckDispose(resp)
CkHttp::ckDispose(http)
ProcedureReturn
EndProcedure
|