Microsoft Advertising API
A Microsoft API that provides programmatic access to Microsoft Advertising to manage large campaigns or to integrate your marketing with other in-house systems.
401 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I tried to use the Bing Ads API to count advertising consumption data. I obtained user information according to the documentation, but got an error: Invalid client data. Check the SOAP fault details for more information. TrackingId: 1aab5eae-76ad-474a-b0f1-46d9737878c7.
The following is my code, the running environment is java8;
try {
OAuthWebAuthCodeGrant oAuthWebAuthCodeGrant = new OAuthWebAuthCodeGrant(clientId, Constant.clientSecret,
new URL(Constant.redirectUri), ApiEnvironment.PRODUCTION);
oAuthWebAuthCodeGrant.setState(Constant.clientState);
authorizationData = new AuthorizationData();
authorizationData.setAuthentication(oAuthWebAuthCodeGrant);
authorizationData.setDeveloperToken(Constant.developerToken);
System.out.printf(
"Open a new web browser and navigate to \n\n%s\n\n" +
"Grant consent in the web browser for the application to access " +
"your advertising accounts, and then enter the response URI that includes " +
"the authorization 'code' parameter: \n",
((OAuthWebAuthCodeGrant)(authorizationData.getAuthentication())).getAuthorizationEndpoint()
);
Scanner scanner = new Scanner(System.in);
java.lang.String responseUri = scanner.nextLine();
URL url = new URL(responseUri);
String query = url.getQuery();
if (!query.contains("state=" + Constant.clientState))
{
throw new Exception("The OAuth response state does not match the client request state.");
}
OAuthTokens tokens = ((OAuthWebAuthCodeGrant)(authorizationData.getAuthentication())).requestAccessAndRefreshTokens(url);
ServiceClient<ICustomerManagementService> customerService = new ServiceClient<ICustomerManagementService>(
authorizationData,
ICustomerManagementService.class);
GetUserRequest request = new GetUserRequest();
request.setUserId(null);
User user = customerService.getService().getUser(request).getUser();
log.info("userId=" + user.getId());
} catch (Exception e) {
e.printStackTrace();
}
my pom.xml dependencies:
<dependency>
<groupId>com.microsoft.bingads</groupId>
<artifactId>microsoft.bingads</artifactId>
<version>13.0.15</version>
<exclusions>
<exclusion>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.glassfish.metro</groupId>
<artifactId>wssx-impl</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.3.4</version>
</dependency>
Due to version conflict, the version used is 13.0.15. I have successfully obtained the accessToken, but an error occurred when calling customerService.getService().getUser(request).getUser().