使用bingads API将bing帐户集成到本地系统时,可能会出现CouldNotSubmitBulkDownloadException

时间:2019-07-15 07:58:11

标签: java bing-api bing-ads-api

尝试使用bingads v13 API将帐户结构集成到我的本地系统中时,会出现以下异常。

File bulkFilePath = service1.downloadFileAsync(downloadParameters, null, null).get(); = >Exception occurred in target VM: com.microsoft.bingads.v13.bulk.CouldNotSubmitBulkDownloadException: java.util.concurrent.ExecutionException: com.microsoft.bingads.v13.bulk.ApiFaultDetail_Exception: Invalid client data. Check the SOAP fault details for more information<

问题是,对于某些帐户,我确实收到了Bingads API的响应,并且帐户结构没有任何问题地集成到系统中。但是,对于一组帐户,我得到上述指定的例外。这是代码。

BulkEntityIterable downloadEntities = null;

Calendar lastSyncTime = new GregorianCalendar();
String synchTime = "2019,01,01,04,43,13";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy,MM,dd,HH,mm,ss");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
lastSyncTime = sdf.getCalendar();
lastSyncTime.setTime(sdf.parse(synchTime));


Map<String, List> bingStructList = new HashMap<>();
ArrayOfDownloadEntity entitieStrings2 = new ArrayOfDownloadEntity();
entitieStrings2.getDownloadEntities().add(DownloadEntity.CAMPAIGNS);
entitieStrings2.getDownloadEntities().add(DownloadEntity.AD_GROUPS);
entitieStrings2.getDownloadEntities().add(DownloadEntity.KEYWORDS);
entitieStrings2.getDownloadEntities().add(DownloadEntity.ADS);
entitieStrings2.getDownloadEntities().add(DownloadEntity.TEXT_ADS);
entitieStrings2.getDownloadEntities().add(DownloadEntity.EXPANDED_TEXT_ADS);

BulkServiceManager service1 = (com.microsoft.bingads.v13.bulk.BulkServiceManager) getBulkService();
com.microsoft.bingads.v13.bulk.DownloadParameters downloadParameters = new com.microsoft.bingads.v13.bulk.DownloadParameters();
downloadParameters.setCampaignIds(null);
downloadParameters.setDownloadEntities(entitieStrings2);
downloadParameters.setFileType(com.microsoft.bingads.v13.bulk.DownloadFileType.CSV);
downloadParameters.setLastSyncTimeInUTC(lastSynchTime);
downloadParameters.setResultFileDirectory(new File("/disk2/example/temp/"));
downloadParameters.setResultFileName("MsnACCSync.csv");

File bulkFilePath = service1.downloadFileAsync(downloadParameters, null, null).get(); // exception is thrown here
BulkFileReader reader = new BulkFileReader(bulkFilePath, ResultFileType.FULL_DOWNLOAD, DownloadFileType.CSV);
downloadEntities = reader.getEntities();

// ----------------------------------------------------------------------------------------------------------------------
public Object getBulkService(){
    String namespace3 = "https://bingads.microsoft.com/BulkService/v13";
    try {
    AuthorizationData authorizationData = new AuthorizationData();
        authorizationData.setDeveloperToken(bingDeveloperToken);
        authorizationData.setCustomerId(seCustomerId);
        authorizationData.setAccountId(seAccountId);
        OAuthTokens oauth4 = new OAuthTokens(accessToken, 360000000, refreshToken);
        OAuthWebAuthCodeGrant oAuthWebAuthCodeGrant4 = new OAuthWebAuthCodeGrant(bingClientId, bingSecret, new URL(bingRedirectUrl), oauth4);
        authorizationData.setAuthentication(oAuthWebAuthCodeGrant4);
        BulkService = new BulkServiceManager(authorizationData);
        return BulkService;
    } catch (Exception e) {
        LOGGER.error(e);
    }
}

请帮助!

0 个答案:

没有答案