darklord5113
New Member
- Joined
- Jun 13, 2018
- Messages
- 3
I am running into trouble with a basic authorization API call:
I have multiple accounts through the data source. When I run the below code, it will prompt me once for a singular login/password, but not again for the subsequent procedures. And while the initial API call works , it then assumes each call after is for the same account and not recognizing the other credentials for the other procedures.
Attached is the code for one account, that I then have for each account with different variables/file names:
Two questions:
1- How do I get the other procedures to utilize their unique credentials, or do I have to run these all separately?
2- Ideally, what can I write in here to automatically input the specific credentials into the prompt once I have it running correctly for each account.
Thanks!
I have multiple accounts through the data source. When I run the below code, it will prompt me once for a singular login/password, but not again for the subsequent procedures. And while the initial API call works , it then assumes each call after is for the same account and not recognizing the other credentials for the other procedures.
Attached is the code for one account, that I then have for each account with different variables/file names:
VBA Code:
Dim Request As Object
Dim url As String
Dim Username As String
Dim Password As String
Dim oStream As Object
Const Str_file As String = "filepath/filename.csv"
Dim startdate As Variant
Dim EndDate As Variant
startdate = Format(Range("F3").Value, "mm/dd/yyyy")
EndDate = Format(Range("F5").Value, "mm/dd/yyyy")
Username = "username"
Password = "password"
Set Request = CreateObject("Microsoft.XMLHTTP")
url = "url.here"
Request.Open "GET", url, False
Request.SetRequestHeader "Authorization", "Basic" & ("Username" & ":" & "Password")
Request.Send
Debug.Print Request.Status
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write Request.responseBody
oStream.Savetofile Str_file, 2
oStream.Close
Two questions:
1- How do I get the other procedures to utilize their unique credentials, or do I have to run these all separately?
2- Ideally, what can I write in here to automatically input the specific credentials into the prompt once I have it running correctly for each account.
Thanks!