上传:deleteUploadData

需要授权

删除与上一个上传有关的数据。 立即试用查看示例

除了标准参数之外,此方法还支持参数表中列出的参数。

请求

HTTP 请求

POST https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/customDataSources/customDataSourceId/deleteUploadData

参数

参数名称 说明
路径参数
accountId string 要删除的上传的帐号 ID。
customDataSourceId string 要删除的上传的自定义数据源 ID。
webPropertyId string 要删除的上传的网络媒体资源 ID。

授权

此请求至少需要获得以下任一范围的授权(详细了解身份验证和授权)。

范围
https://www.googleapis.com/auth/analytics
https://www.googleapis.com/auth/analytics.edit

请求正文

在请求正文中,请按以下结构提供数据:

{
  "customDataImportUids": [
    string
  ]
}
属性名称 说明 备注
customDataImportUids[] list 上传 UID 列表。

响应

如果响应成功,此方法会返回空的响应正文。

示例

备注:此方法的代码示例并未列出所有受支持的编程语言(请参阅客户端库页面,查看受支持的语言列表)。

Java

使用 Java 客户端库

/*
 * Note: This code assumes you have an authorized Analytics service object.
 * See the Data Import Developer Guide for details.
 */

// Construct a list of file ids to delete.
List<String> filesToDelete = Arrays.asList("ZYXABC123zyxabc",
    "lmnopEFGXYZ123a", "999AAA888bbb777");

// Construct the body of the Delete Request and set the file ids.
AnalyticsDataimportDeleteUploadDataRequest body = new
    AnalyticsDataimportDeleteUploadDataRequest();
body.setCustomDataImportUids(filesToDelete);

// This request deletes three uploaded files for the authorized user.
try {
  analytics.management().uploads().deleteUploadData("123456",
      "UA-123456-1", "122333444455555", body).execute();
} catch (GoogleJsonResponseException e) {
  System.err.println("There was a service error: "
      + e.getDetails().getCode() + " : "
      + e.getDetails().getMessage());
}

PHP

使用 PHP 客户端库

/**
 * Note: This code assumes you have an authorized Analytics service object.
 * See the Data Import Developer Guide for details.
 */

// Construct a list of upload ids to delete.
$uploadIds = array('ABBCCCDDDDEEEEE');

// Construct the body of the Delete Request and set the upload ids.
$body = new
    Google_Service_Analytics_AnalyticsDataimportDeleteUploadDataRequest();
$body->setCustomDataImportUids($uploadIds);

// This request deletes the uploads.
try {
  $uploads = $analytics->management_uploads->deleteUploadData('123456',
      'UA-123456-1', '122333444455555', $body);

} catch (apiServiceException $e) {
  print 'There was an Analytics API service error '
      . $e->getCode() . ':' . $e->getMessage();

} catch (apiException $e) {
  print 'There was a general API error '
      . $e->getCode() . ':' . $e->getMessage();
}

Python

使用 Python 客户端库

# Note: This code assumes you have an authorized Analytics service object.
# See the Data Import Developer Guide for details.

# This request deletes a list of uploads.
try:
  analytics.management().uploads().deleteUploadData(
      accountId='123456',
      webPropertyId='UA-123456-1',
      customDataSourceId='ABCDEFG123456abcdefg',
      body={
          'customDataImportUids': ['ZYXABC123zyxabc',
                                   'lmnopEFGXYZ123a',
                                   '999AAA888bbb777']
      }
  ).execute()

except TypeError, error:
  # Handle errors in constructing a query.
  print 'There was an error in constructing your query : %s' % error

except HttpError, error:
  # Handle API errors.
  print ('There was an API error : %s : %s' %
         (error.resp.status, error.resp.reason))

JavaScript

使用 JavaScript 客户端库

/*
 * Note: This code assumes you have an authorized Analytics client object.
 * See the Data Import Developer Guide for details.
 */

/*
 * This request deletes a list of existing uploads.
 */
function deleteUploads() {
  var request = gapi.client.analytics.management.uploads.deleteUploadData({
    'accountId': '123456',
    'webPropertyId': 'UA-123456-1',
    'customDataSourceId': 'ABCDEFG123abcDEF123',
    'resource': {
      'customDataImportUids': ['AAABBBCCCDDD111222',
                               'xLh4wXtzQT6uxe-_OWelog']
    }
  });
  request.execute(function (response) { // Handle the response. });
}

立即试用!

请使用下面的 API Explorer 针对实时数据调用此方法并查看响应。或者,您还可以尝试使用独立的 Explorer