0

I have a bunch of API calls to STRIPE which are working well. Generally I use the cURL version and work out what I need to do.

I have just come across the need to DELETE a subscription:

   curl https://api.stripe.com/v1/subscriptions/sub_FpZkRarex4obNX \
  -u sk_test_VHkTM0bOtpsE1dBnTxFbMBAk00WnBQnyI5: \
  -X DELETE

The issue is I have no idea how to use the -x in VBA

My current code for other calls is:

api_Key = getStripeAPI

req = "DELETE"

Set httpReq = CreateObject("MSXML2.ServerXMLHTTP")
httpReq.Open "POST", "https://api.stripe.com/v1/subscriptions/" & stripeSubID, False

httpReq.setRequestHeader "Authorization", "Bearer " & api_Key
httpReq.send req
strResponse = httpReq.responseText
Debug.Print strResponse
writeToText strResponse
Set parsed = JsonConverter.ParseJson(strResponse)

I know the above code is incorrect but if someone can let me know how to utilise -X that would be great.

2 Answers 2

2

You're already using it, just passing the wrong argument. It's the first argument to .Open:

httpReq.Open "DELETE", "https://api.stripe.com/v1/subscriptions/" & stripeSubID, False
Sign up to request clarification or add additional context in comments.

Comments

1

ok wow i just figured it by myself.. after 45 mins of trying.

For those looking fr this:

-x DELETE means use DELETE as the "GET"/"POST" option.

working code:

api_Key = getStripeAPI



Set httpReq = CreateObject("MSXML2.ServerXMLHTTP")
httpReq.Open "DELETE", "https://api.stripe.com/v1/subscriptions/" & stripeSubID, False

httpReq.setRequestHeader "Authorization", "Bearer " & api_Key
httpReq.send
strResponse = httpReq.responseText
Debug.Print strResponse
writeToText strResponse
Set parsed = JsonConverter.ParseJson(strResponse)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.