Sample code for 30+ languages & platforms
AutoIt

MYOB: Delete a Category

See more MYOB Examples

Sends a DELETE to delete a category.

Chilkat AutoIt Downloads

AutoIt
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")

; Implements the following CURL command:

; curl --request DELETE "https://ar1.api.myob.com/accountright/c06778dd-4371-4a83-975f-522df65d7574/GeneralLedger/Category/{{category_id}}" \
;   --header "Authorization: Bearer ACCESS_TOKEN" \
;   --header "x-myobapi-key: This is your API Key" \
;   --header "x-myobapi-version: v2" \
;   --header "Accept-Encoding: gzip,deflate"

$oHttp.SetRequestHeader "Authorization","Bearer ACCESS_TOKEN"
$oHttp.SetRequestHeader "x-myobapi-key","This is your API Key"
$oHttp.SetRequestHeader "Accept-Encoding","gzip,deflate"
$oHttp.SetRequestHeader "x-myobapi-version","v2"

$oResp = ObjCreate("Chilkat.HttpResponse")
$bSuccess = $oHttp.HttpNoBody("DELETE","https://ar1.api.myob.com/accountright/c06778dd-4371-4a83-975f-522df65d7574/GeneralLedger/Category/{{category_id}}",$oResp)
If ($bSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

Local $iRespStatusCode = $oResp.StatusCode
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode <> 200) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oResp.Header & @CRLF)
    ConsoleWrite("Response Body:" & @CRLF)
    ConsoleWrite($oResp.BodyStr & @CRLF)
    ConsoleWrite("Failed." & @CRLF)
    Exit
EndIf

ConsoleWrite("Success." & @CRLF)