Created
October 18, 2013 11:03
-
-
Save IronistM/7039991 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
postDailyCustomDataSource = function(filename = "./YandexUpload/cost.data.splits.2013_02_11.csv", | |
accountId=GA.profiles$accountId[52], #uploading to 52nd accountId | |
webPropertyId=GA.profiles$webPropertyId[52], | |
customDataSourceId="XXXXX", | |
date = '2013-02-11', | |
access_token = MEtoken) { | |
# Verified this is correct URL as it works in curl | |
url2 <- paste0('https://www.googleapis.com/upload/analytics/v3/management/accounts/', accountId , | |
'/webproperties/', webPropertyId, | |
'/customDataSources/', customDataSourceId, | |
'/dailyUploads/', date, '/uploads?', | |
'access_token=', access_token, | |
'&type=cost', | |
'&appendNumber=1' | |
); | |
# Returns "Error: Bad Request" | |
# rawData <- postForm(url2, | |
# upload = fileUpload(filename = filename, | |
# contentType = "application/octet-stream" | |
# ), | |
# .encoding = "utf-8", | |
# style = 'POST') | |
# Works, uploads file | |
syscommand <- system(paste0('curl -X POST "',url2,'" -F "upload=@',filename,';type=application/octet-stream"'), | |
intern = TRUE) | |
#return(rawData) | |
return(syscommand) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment