hi developing application in salesforce accessing google adwords reports data e.g. adgroup_performance_report. sending http post request https://adwords.google.com/api/adwords/reportdownload/v201302, , using apex(java language in salesforce) below request.
http h = new http(); httprequest req = new httprequest(); googleauthorization auth=new googleauthorization(); req.setheader('authorization', 'googlelogin ' + auth.token); req.setheader('useragent', 'xxxxx'); req.setheader('developertoken','xxxxxxxx'); req.setheader('clientcustomerid','xxxxxxxx'); req.setendpoint('https://adwords.google.com/api/adwords/reportdownload/v201302'); req.setheader('content-type', 'application/x-www-form-urlencoded'); req.setmethod('post'); string xml='<reportdefinition xmlns="https://adwords.google.com/api/adwords/cm/v201302">'+ '<selector>'+ '<fields>campaignid</fields>'+ '<fields>id</fields>'+ '<fields>impressions</fields>'+ '<fields>clicks</fields>'+ '<fields>cost</fields>'+ '<predicates>'+ '<field>status</field>'+ '<operator>in</operator>'+ '<values>enabled</values>'+ '<values>paused</values>'+ '</predicates>'+ '</selector>'+ '<reportname>custom adgroup performance report</reportname>'+ '<reporttype>adgroup_performance_report</reporttype>'+ '<daterangetype>last_7_days</daterangetype>'+ '<downloadformat>xml</downloadformat>'+ '</reportdefinition>'; req.setbody('__rdxml='+encodingutil.urlencode(xml, 'utf-8')); httpresponse res=h.send(req);
after requesting getting authenticationerror system.httpresponse[status=bad request, statuscode=400].
<?xml version="1.0" encoding="utf-8" standalone="yes"?><reportdownloaderror><apierror><type>authenticationerror.user_id_invalid</type><trigger><null></trigger><fieldpath></fieldpath></apierror></reportdownloaderror>
however loginid , password correct. doing wrong can please help!
check app's configuration. must have there :
<adwordsapi> <add key="maskcredentials" value="true" /> <add key="enablegzipcompression" value="true" /> <add key="proxyserver" value="" /> <add key="proxyuser" value="" /> <add key="proxypassword" value="" /> <add key="proxydomain" value="" /> <add key="useragent" value="*******" /> <add key="developertoken" value="*******" /> <add key="clientcustomerid" value="*******" /> <add key="skipreportheader" value="false" /> <add key="skipreportsummary" value="false" /> <add key="oauth2clientid" value="*******" /> <add key="oauth2clientsecret" value="*******" /> <add key="oauth2mode" value="application" /> <add key="oauth2refreshtoken" value="1/*******" /> </adwordsapi>
fill required values *****.
Comments
Post a Comment