1

This code creates a download but not of the linked file as it is not direct. When I open the .csv file it downloads, it appears to be the data from the redirect, not the file linked to the redirect.

This is the code:

Sub Asana()

Dim myURL As String
myURL = "https://app.asana.com/-/csv?id=955497629707333"

Dim HttpReq As Object
Set HttpReq = CreateObject("Microsoft.XMLHTTP")
HttpReq.Open "GET", myURL, False, "username", "password"
HttpReq.send


myURL = HttpReq.responseBody
If HttpReq.Status = 200 Then
    Set oStrm = CreateObject("ADODB.Stream")
    oStrm.Open
    oStrm.Type = 1
    oStrm.Write HttpReq.responseBody
    oStrm.SaveToFile ThisWorkbook.Path & "\" & "SER_Backlog_BRCC.csv", 2 ' 1 = no overwrite, 2 = overwrite
    oStrm.Close
End If

End Sub

It should be a spreadsheet copy of the data on the page, but it comes out with data in a spreadsheet of the website and not the linked .csv file you would get, if done manually.

DOCHTML

Should be this:

should be this.

Asger
  • 3,822
  • 3
  • 12
  • 37
LLF
  • 53
  • 7

1 Answers1

0

I guess, you have an authorization problem, as user/password is not supported by Asana.
You need a Personal Access Token, which has to be set in your request header.

Please replace this line

'Set HttpReq = CreateObject("Microsoft.XMLHTTP")
Set HttpReq = CreateObject("MSXML2.XMLHTTP")

and that line:

'HttpReq.Open "GET", myURL, False, "username", "password"
HttpReq.Open "GET", myURL, False
HttpReq.setRequestHeader "Authorization", "Bearer " & "your Asana token here"
Asger
  • 3,822
  • 3
  • 12
  • 37
  • That did not work, it download the same DOCTYPEhtml file. – LLF Jun 10 '19 at 16:05
  • So you still have an authorization problem, as that is the result I also get, if I don't provide *any* Asana token. Maybe you should ask your question at https://forum.asana.com. – Asger Jun 11 '19 at 08:36