-1

I'm trying to get Excel to download a CSV file, from a link that changes by the day, with a click on a button. The thing is, it's locked behind an agreement-number, ID and password.

I, however, got two API tokens:

TheAppSecretToken

TheAgreementGrantToken

The link is:

https://secure.e-conomic.com/secure/generelt/exportdata2.asp?mode=doexport&kartotek=5&fradato=01-01-2017&tildato=01-02-2018&vcseparator=%3B&vcQualifier=%22

If people have another way, than using a VBA-code, to download this file with a click on a button, don't hold back with the suggestion.

I appreciate any help I can get, thank you. :-)

EDIT: It's not a duplicate for another question, as this uses Tokens, and or 3 login informations.

EDIT2: nvm. that the link is changing from day-to-day, I figured out that I can just put the date as far out in the future, as I like.

braX
  • 11,506
  • 5
  • 20
  • 33
Blab
  • 235
  • 2
  • 9
  • Possible duplicate of [How do i download a file using VBA (Without internet explorer)](https://stackoverflow.com/questions/17877389/how-do-i-download-a-file-using-vba-without-internet-explorer) – tomichel Feb 01 '18 at 10:36

1 Answers1

0

Edit:

I assume that the login call needs to be an POST request, but this is only a guess as I can't test it with the information you have given

Just change the loginBody with the information you need or change it to the format that the URL needs (like JSON) and you can send as many information as need

If needed you can also set more headers for any other tokens you have

URL = "YOURURL"
loginBody = "username=username&password=password&token=token"

HttpObj.Open("POST", URL)
HttpObj.SetRequestHeader("Content-Type","application/x-www-form-urlencoded")
HttpObj.Send(loginBody)

Old answer:

As I'm not allowed to comment it seems what you are trying to do is explained here:

How do i download a file using VBA (Without internet explorer)

tomichel
  • 376
  • 1
  • 4
  • 9
  • Problem with that is, that the code only include ID and pass, but I also have to put in an agreement number as shown here: https://imgur.com/a/NzAbX – Blab Feb 01 '18 at 11:32
  • Do I need to use Agreement-ID, Username & Pass, if I have the tokens? – Blab Feb 01 '18 at 12:40
  • I would suggest that you read the API documentation about it, but if you got a token after you logged in against an token/login endpoint it could very well be that you don't need to authenticate again with username/password and use the token instead – tomichel Feb 01 '18 at 12:43