AutoIt
AutoIt
ShopwareDelete Product
See more Shopware Examples
Deletes a product in Shopware.Chilkat AutoIt Downloads
Local $bSuccess = False
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oHttp = ObjCreate("Chilkat.Http")
$oHttp.Login = "api_username"
$oHttp.Password = "api_key"
$oHttp.BasicAuth = True
; The id of the product is appended to the path part of the URL.
$oHttp.SetUrlVar("id","8312")
Local $sUrl = "https://my-shopware-shop.com/api/articles/{$id}"
; Send a DELETE request with nothing in the request body.
$oResp = ObjCreate("Chilkat.HttpResponse")
$bSuccess = $oHttp.HttpNoBody("DELETE",$sUrl,$oResp)
If ($bSuccess = False) Then
ConsoleWrite($oHttp.LastErrorText & @CRLF)
Exit
EndIf
$oSbResponseBody = ObjCreate("Chilkat.StringBuilder")
$oResp.GetBodySb($oSbResponseBody)
$oJResp = ObjCreate("Chilkat.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False
ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)
; A 200 response code indicates success (i.e. the request was sent and a response was received).
Local $iRespStatusCode = $oResp.StatusCode
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
ConsoleWrite("Response Header:" & @CRLF)
ConsoleWrite($oResp.Header & @CRLF)
ConsoleWrite("Failed." & @CRLF)
Exit
EndIf
; Sample JSON response:
; {
; "success": true
; }
Local $bDeleted = $oJResp.BoolOf("success")
ConsoleWrite("Deleted: " & $bDeleted & @CRLF)
; A failed response would look like this:
; {
; "success": false,
; "message": "Product by \"id\" 8312 not found"
; }