(PureBasic) HTTP DELETE with Body
Demonstrates how to send a DELETE request with a body. Note: This example requires Chilkat v11.0.0 or greater.
IncludeFile "CkHttpResponse.pb"
IncludeFile "CkHttp.pb"
Procedure ChilkatExample()
success.i = 0
; 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 HttpStr method (or HttpSb) to send a DELETE request with a body.
requestBody.s = "{ " + Chr(34) + "abc" + Chr(34) + ": 123 }"
resp.i = CkHttpResponse::ckCreate()
If resp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkHttp::ckHttpStr(http,"DELETE","https://example.com/something",requestBody,"utf-8","application/json",resp)
If success = 0
Debug CkHttp::ckLastErrorText(http)
CkHttp::ckDispose(http)
CkHttpResponse::ckDispose(resp)
ProcedureReturn
EndIf
Debug "Response status: " + Str(CkHttpResponse::ckStatusCode(resp))
Debug "Response body: "
Debug CkHttpResponse::ckBodyStr(resp)
CkHttp::ckDispose(http)
CkHttpResponse::ckDispose(resp)
ProcedureReturn
EndProcedure
|