PowerShell
PowerShell
ShopwareDelete Product
See more Shopware Examples
Deletes a product in Shopware.Chilkat PowerShell Downloads
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"
$success = $false
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
$http = New-Object Chilkat.Http
$http.Login = "api_username"
$http.Password = "api_key"
$http.BasicAuth = $true
# The id of the product is appended to the path part of the URL.
$http.SetUrlVar("id","8312")
$url = "https://my-shopware-shop.com/api/articles/{$id}"
# Send a DELETE request with nothing in the request body.
$resp = New-Object Chilkat.HttpResponse
$success = $http.HttpNoBody("DELETE",$url,$resp)
if ($success -eq $false) {
$($http.LastErrorText)
exit
}
$sbResponseBody = New-Object Chilkat.StringBuilder
$resp.GetBodySb($sbResponseBody)
$jResp = New-Object Chilkat.JsonObject
$jResp.LoadSb($sbResponseBody)
$jResp.EmitCompact = $false
$("Response Body:")
$($jResp.Emit())
# A 200 response code indicates success (i.e. the request was sent and a response was received).
$respStatusCode = $resp.StatusCode
$("Response Status Code = " + $respStatusCode)
if ($respStatusCode -ge 400) {
$("Response Header:")
$($resp.Header)
$("Failed.")
exit
}
# Sample JSON response:
# {
# "success": true
# }
$bDeleted = $jResp.BoolOf("success")
$("Deleted: " + $bDeleted)
# A failed response would look like this:
# {
# "success": false,
# "message": "Product by \"id\" 8312 not found"
# }