The documentation gives the following format for cancelling a specific order:
DELETE /v2/orders/{order_id}
However, when I use Access VBA to send the DELETE message it returns a “405 Not Allowed” error. POST and GET methods are working fine.
(API key and secret are set in constants earlier)
Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
Const strEndPoint As String = "https://paper-api.alpaca.markets/v2/orders/"
(myBrkrId is a string containing the Alpaca order ID)
payload_json = "{""" & myBrkrId & """}"
Debug.Print strEndPoint & payload_json
objHTTP.Open "DELETE", strEndPoint, False
objHTTP.setRequestHeader "APCA-API-KEY-ID", ALPACA_API_KEY
objHTTP.setRequestHeader "APCA-API-SECRET-KEY", ALPACA_API_SECRET_KEY
objHTTP.Send payload_json
Debug.Print objHTTP.STATUS
byteData = objHTTP.responseBody
Set objHTTP = Nothing
ALPCXLORDER = StrConv(byteData, vbUnicode)
Debug.Print ALPCXLORDER
Resulting API call:
https://paper-api.alpaca.markets/v2/orders/{“e2fdba6a-a01b-401f-92b9-6d4eb5c9fba8”}