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