1
我想上傳一個CSV文件使用谷歌分析API,它給了我一個失敗的狀態。 我得到的錯誤是可變的爲null:參數名稱基地uri無法上傳CSV文件使用谷歌分析API在C#
我已經在開發人員控制檯中授予了Google Analytics(分析)API的權限,並且我使用服務帳戶來生成密鑰和ID。
這是我的代碼片斷
const string serviceAccountEmail = "[email protected]";
const string serviceAccountPKCSP12FilePath = @"C:\SVN\GAPforInboundandWeb-1f6bfb.p12";
X509Certificate2 certificate = new X509Certificate2(serviceAccountPKCSP12FilePath, "notasecret", X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { AnalyticsService.Scope.Analytics }
}.FromCertificate(certificate));
var service = new AnalyticsService(new BaseClientService.Initializer
{
HttpClientInitializer = credential,
ApplicationName = "GAPforInboundandWeb"
});
FileStream realCsv = new FileStream("c:\\real.csv", FileMode.Open);
// Create the service.
try
{
var upload = service.Management.DailyUploads.Upload("50288725", "UA-50288725-1", "Oy_0JTPvRGCB3Vg5OKVIMQ",
"2014-09-22", 1, ManagementResource.DailyUploadsResource.UploadMediaUpload.TypeEnum.Cost, realCsv,
"application/octet-stream");
upload.Reset = true;
var res = upload.Upload();
res.BytesSent.ToString();
res.Status.ToString();
}
那麼,它是空的? – Casey 2014-09-24 04:05:36