Any help much appreciated. Im trying to send a request to recieve an access token in VBA.
The suggested format is curl --request POST --url 'Sign in to your account{tenantId}/oauth2/v2.0/token' --header 'content-type: application/x-www-form-urlencoded' --data grant_type=client_credentials --data client_id=CLIENT_ID_HERE --data client_secret=CLIENT_SECRET_HERE --data scope=https://tapi.dvsa.gov.uk/.default
But I want to send this using Excel VBA so far I have this, But I cant get the data to send
API_TOKENURL = ""
API_ID = ""
API_Secret = ""
API_KEY = ""
API_APPLICATION = "application/json"
Set DvlaService = CreateObject("MSXML2.XMLHTTP")
DvlaService.Open "POST", "Sign in to your account", False
DvlaService.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
data = "grant_type=client_credentials"
data = data & "&data-client_id=" & Application.EncodeURL("5683e80b-e549-4721-b1e2-441fa19c9847")
data = data & "&data-client_secret=" & Application.EncodeURL("iZk8Q~-ClQzJ-6NTiOLq6JrkQDiSH3AwlwklYb..")
data = data & "&data-scope=" & Application.EncodeURL("https://tapi.dvsa.gov.uk/.default")
DvlaService.send data
Response = DvlaService.responseText
MsgBox Response
Im still very new to this , so any help or pointers would be great
The suggested format is curl --request POST --url 'Sign in to your account{tenantId}/oauth2/v2.0/token' --header 'content-type: application/x-www-form-urlencoded' --data grant_type=client_credentials --data client_id=CLIENT_ID_HERE --data client_secret=CLIENT_SECRET_HERE --data scope=https://tapi.dvsa.gov.uk/.default
But I want to send this using Excel VBA so far I have this, But I cant get the data to send
API_TOKENURL = ""
API_ID = ""
API_Secret = ""
API_KEY = ""
API_APPLICATION = "application/json"
Set DvlaService = CreateObject("MSXML2.XMLHTTP")
DvlaService.Open "POST", "Sign in to your account", False
DvlaService.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
data = "grant_type=client_credentials"
data = data & "&data-client_id=" & Application.EncodeURL("5683e80b-e549-4721-b1e2-441fa19c9847")
data = data & "&data-client_secret=" & Application.EncodeURL("iZk8Q~-ClQzJ-6NTiOLq6JrkQDiSH3AwlwklYb..")
data = data & "&data-scope=" & Application.EncodeURL("https://tapi.dvsa.gov.uk/.default")
DvlaService.send data
Response = DvlaService.responseText
MsgBox Response
Im still very new to this , so any help or pointers would be great