Sending my first request

77 views
Skip to first unread message

Orlie

unread,
Sep 17, 2015, 1:49:46 PM9/17/15
to AdWords API Forum
I'm stuck trying to get the example with cURL from the page to work: https://developers.google.com/adwords/api/docs/guides/basic-concepts

The code 

<?xml version="1.0" encoding="UTF-8"?>
  <soapenv:Header>
<ns1:RequestHeader soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201506">
  <ns1:clientCustomerId>MY_TEST_ACCOUNT_ID</ns1:clientCustomerId>
  <ns1:developerToken>MY_NON_APPROVED_TOKEN</ns1:developerToken>
  <ns1:userAgent>Foo Bar (fizzbuzz)</ns1:userAgent>
  <ns1:validateOnly>false</ns1:validateOnly>
  <ns1:partialFailure>false</ns1:partialFailure>
</ns1:RequestHeader>
  </soapenv:Header>
  <soapenv:Body>
  <operations>
    <operator>ADD</operator>
    <operand>
      <name>Hello World</name>
      <status>PAUSED</status>
      <budget>
        <budgetId>987654321</budgetId>
      </budget>
      <settings xsi:type="ns2:GeoTargetTypeSetting" xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201506">
        <positiveGeoTargetType>DONT_CARE</positiveGeoTargetType>
      </settings>
      <settings xsi:type="ns3:KeywordMatchSetting" xmlns:ns3="https://adwords.google.com/api/adwords/cm/v201506">
        <optIn>false</optIn>
      </settings>
      <networkSetting>
        <targetGoogleSearch>true</targetGoogleSearch>
        <targetSearchNetwork>true</targetSearchNetwork>
        <targetContentNetwork>false</targetContentNetwork>
      </networkSetting>
      <biddingStrategyConfiguration>
        <biddingScheme xsi:type="ns4:ManualCpcBiddingScheme" xmlns:ns4="https://adwords.google.com/api/adwords/cm/v201506">
          <enhancedCpcEnabled>false</enhancedCpcEnabled>
        </biddingScheme>
      </biddingStrategyConfiguration>
    </operand>
  </operations>
</mutate>
  </soapenv:Body>
</soapenv:Envelope>

I've got my Oauth token and I copy pasted and replaced the values in the example payload with my own details but when I try to run it it outputs an error

curl --header "Content-Type: application/soap+xml" \                                                                                                         
     --header "Authorization : Bearer ya29.LONGLONGLONGSTRING" \
     --data @data.xml \

And the error:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>Unmarshalling Error: cvc-elt.4.2: Cannot resolve 'ns3:KeywordMatchSetting' to a type definition for element 'settings'. </faultstring></soap:Fault></soap:Body></soap:Envelope>

Then if I remove that line from the XML file...

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Header><ResponseHeader xmlns="https://adwords.google.com/api/adwords/cm/v201506"><requestId>00051ff3c60626180abfa5415a00309c</requestId><serviceName>CampaignService</serviceName><methodName>mutate</methodName><operations>0</operations><responseTime>40</responseTime></ResponseHeader></soap:Header><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>[AuthenticationError.OAUTH_TOKEN_INVALID @ ; trigger:'&lt;null&gt;']</faultstring><detail><ApiExceptionFault xmlns="https://adwords.google.com/api/adwords/cm/v201506"><message>[AuthenticationError.OAUTH_TOKEN_INVALID @ ; trigger:'&lt;null&gt;']</message><ApplicationException.Type>ApiException</ApplicationException.Type><errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="AuthenticationError"><fieldPath></fieldPath><trigger>&lt;null&gt;</trigger><errorString>AuthenticationError.OAUTH_TOKEN_INVALID</errorString><ApiError.Type>AuthenticationError</ApiError.Type><reason>OAUTH_TOKEN_INVALID</reason></errors></ApiExceptionFault></detail></soap:Fault></soap:Body></soap:Envelope>


I don't understand how the first example and I can still get it wrong?

Any pointers on how to solve is appreciated!

best,

Anthony Madrigal

unread,
Sep 17, 2015, 4:54:23 PM9/17/15
to AdWords API Forum
Hi Orlie,

The error you are getting indicates that your OAuth token may be expired. You could check to see if your token is still valid by appending it to this link in place of MY_TOKEN: https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=MY_TOKEN
You may want to generate a new Refresh Token if this is still failing.

Please also make sure that your clientCustomerId is an ID that corresponds to an AdWords client account, not an MCC manager account.

Let me know if you are still running into any issues.

Regards,
Anthony
AdWords API Team

Orlie

unread,
Sep 17, 2015, 5:38:28 PM9/17/15
to AdWords API Forum
I'm pretty sure my Oauth is right because I was doing the whole Oauth flow separately..

However: I have been working on it trying to resolve since yesterday, so I gave up and used your Google Ads library instead. 

Thanks!

Kurt Wheeler

unread,
May 10, 2016, 2:49:16 PM5/10/16
to AdWords API Forum
Hello,

It's a shame this didn't ever get resolved. Almost a year later I am getting the same error using the sample XML provided by the guide. Anthony said "The error you are getting indicates that your OAuth token may be expired." but that error does not indicate that the OAuth token is expired. It may be caused by it, but it certainly doesn't indicate it. However when I run my code I am generating an OAuth access_token immediately before making this request so I know that there's no way it could be expired. I also know that my refresh token is valid for the same reason: if it wasn't I wouldn't be able to generate the access token. My use case does not require a mutate operation so I am going to see if I can get this working with a simple get. It sounds like there's a good chance the error message being returned is actually unrelated to my issue though so I may run into the issue doing a get as well.

It seems like either the sample XML on the "Basic Concepts" should be changed so that an error message isn't returned or the error handling code should be changed to return an error message that does indicate what the error is instead of returning a red herring message related to provided sample code.

Kurt Wheeler

unread,
May 10, 2016, 3:23:00 PM5/10/16
to AdWords API Forum
Update: I was able to get a successful 200 response back making a get operation. That means that all my code dealing with the request was fine, the only issue was with the provided example XML.

Josh Radcliff (AdWords API Team)

unread,
May 10, 2016, 4:56:50 PM5/10/16
to AdWords API Forum
Hi Kurt,

Sorry this wasn't resolved for you before. I just took a look at the example and confirmed that the XML is indeed outdated. I'm working on updating that now and will reply back as soon as that's done.

Thanks,
Josh, AdWords API Team

Josh Radcliff (AdWords API Team)

unread,
May 10, 2016, 6:03:42 PM5/10/16
to AdWords API Forum
Hi Kurt,

I just updated the XML in the Basic concepts guide and confirmed that it worked as expected once I substituted in my developer token, client customer ID, and budget ID. Please let me know if the latest version still gives you trouble.

Cheers,
Josh, AdWords API Team
Reply all
Reply to author
Forward
0 new messages