Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unmarshalling Error: cvc-complex-type.2.4.a: Invalid content was found starting with element '{"https://adwords.google.com/api/adwords/cm/v201809":query}'. One of '{"https://adwords.google.com/api/adwords/cm/v201809":serviceSelector}' is expected. #106

Open
Jared-Dahlke opened this issue Mar 6, 2020 · 1 comment

Comments

@Jared-Dahlke
Copy link

Jared-Dahlke commented Mar 6, 2020

Hello and thank you for the package Chris! I finally managed to get the authentication working but am now getting an error. Here is my code, followed by the error:


const AdwordsUser = require('node-adwords').AdwordsUser;
const refreshToken = '1/adsfasdfadadfadfadfadfadf'
const keys = require('../../GoogleAdsApiCredentials.json');
const {JWT} = require('google-auth-library');

`const client = new JWT(
      keys.client_email,
      null,
      keys.private_key,
      ['https://www.googleapis.com/auth/adwords'],
    );
    const mytoken = await client.getAccessToken();
    client.refreshToken(refreshToken)   
    let user = new AdwordsUser({
      developerToken:  keys.devToken, //your adwords developerToken
      userAgent: 'myCompanyNqme', //any company name
      clientCustomerId: '111-111-1111',  //the Adwords Account id (e.g. 123-123-123)
      client_id: '1231231231-4tao4aeumsg0hadsfasdfanpve.apps.googleusercontent.com', //this is the api console client_id
      client_secret: 'adshjkflajsldfjaldjhfla',
      refresh_token: refreshToken, 
      access_token: mytoken.token
    });

    let campaignService = user.getService('CampaignService', 'v201809')
   
    let params = {
      query: 'SELECT Id, Name'
  };
   
  campaignService.get(params, (error, result) => {
    //console.log(JSON.stringify(result));
    console.log(error)
  })

here is the request body that the above code generates using this library:
body: '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="https://adwords.google.com/api/adwords/cm/v201809" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"><soap:Header><ns1:RequestHeader xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201809" xmlns="https://adwords.google.com/api/adwords/cm/v201809"><ns1:developerToken>adfadadffadf</ns1:developerToken><ns1:userAgent>Sightly</ns1:userAgent><ns1:validateOnly>false</ns1:validateOnly><ns1:clientCustomerId>111-111-1111</ns1:clientCustomerId></ns1:RequestHeader></soap:Header><soap:Body><get xmlns="https://adwords.google.com/api/adwords/cm/v201809"><query>SELECT Id, Name</query></get></soap:Body></soap:Envelope>'

and finally the error I am getting when I call this is below:
toJSON: [Function: responseToJSON],
caseless: Caseless { dict: [Object] },
body: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Unmarshalling Error: cvc-complex-type.2.4.a: Invalid content was found starting with element '{"https://adwords.google.com/api/adwords/cm/v201809":query}'. One of '{"https://adwords.google.com/api/adwords/cm/v201809":serviceSelector}' is expected. </faultstring></soap:Fault></soap:Body></soap:Envelope>
},
body: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Unmarshalling Error: cvc-complex-type.2.4.a: Invalid content was found starting with element '{"https://adwords.google.com/api/adwords/cm/v201809":query}'. One of '{"https://adwords.google.com/api/adwords/cm/v201809":serviceSelector}' is expected. </faultstring></soap:Fault></soap:Body></soap:Envelope>
}
Hopefully someone can help. Thank you

@jtiscione
Copy link

It looks like Google broke this library. Even the README code throws this error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants