getting unmarshalling error on radiusInUnits using CampaignCriterionService

40 views
Skip to first unread message

thom hickey

unread,
May 9, 2017, 3:10:41 PM5/9/17
to AdWords API Forum
Hello,

We're using the API and everything worked on the test accounts. We applied for basic access and were approved. When our code hit our production environment we're getting:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <soap:Fault> <faultcode>soap:Client</faultcode> <faultstring>Unmarshalling Error: 00:00:50Z</faultstring> </soap:Fault> </soap:Body> </soap:Envelope>

The criterion it's complaining about is:

<ns1:radiusInUnits>00:00:50Z</ns1:radiusInUnits>

But the problem is we're setting that radius as 50 and somehow it comes out as '00:00:50Z'. Any ideas what is happening here? The same data run through our local and dev systems works fine and we see:

<ns1:radiusInUnits>50</ns1:radiusInUnits>

in the logs and the mutation is successful. Really scratching our heads with this one. Also, if we force '00:00:50Z' into the radius value we get back a clean CriterionError.INVALID_PROXIMITY_RADIUS

I read all the other 'unmarshalling' posts here and they all seem to have a much more explicit error message than we're getting. Any help appreciated.

AwApi-PHP, googleads-php-lib/25.4.0, PHP/5.6.27
v201702

-Thom

Shwetha Vastrad (AdWords API Team)

unread,
May 9, 2017, 4:43:08 PM5/9/17
to AdWords API Forum
Hi Thom, 

Could you provide more details on how you are adding this CampaignCriterion in question? It looks like the value sent in the radiusInUnits is being formatted incorrectly in your production environment. The API expects a double value for the radiusInUnits field. The following code snippet can be used to add a Proximity criterion using the PHP client library: 

    $proximity = new Proximity();
    $proximity
->setAddress($address);
    $proximity
->setRadiusDistanceUnits(ProximityDistanceUnits::KILOMETERS);
    $proximity
->setRadiusInUnits(50);

Regards,
Shwetha, AdWords API Team.

thom hickey

unread,
May 9, 2017, 5:58:16 PM5/9/17
to AdWords API Forum
Thanks, Shwetha. Here's the snippet. Incidentally it works in PHP 7. I've also added to an issue with the php lib devs on GitHub about this problem as perhaps it's a client-side issue?


/**
* returns spend areas in Proximity array
* @param array $spend_areas
* @return mixed
*/
public function spendsToCampaignCriteria( $campaign_id, $spend_areas )
{
$proximities = [];
foreach ( $spend_areas as $spend_area )
{
$geo_point = new GeoPoint();
$geo_point->setLatitudeInMicroDegrees( $spend_area[ 'latitude' ] * 1000000 );
$geo_point->setLongitudeInMicroDegrees( $spend_area[ 'longitude' ] * 1000000 );
$proximity = new Proximity();
$proximity->setRadiusInUnits( $spend_area[ 'radius' ] );
$proximity->setRadiusDistanceUnits( ProximityDistanceUnits::MILES );
$proximity->setGeoPoint( $geo_point );
$proximities[] = new CampaignCriterion( $campaign_id, null, $proximity );
}
return $proximities;
}

Shwetha Vastrad (AdWords API Team)

unread,
May 10, 2017, 11:22:25 AM5/10/17
to AdWords API Forum
Hi Thom, 

It does look like an issue specific to the PHP client library. Since you have already opened an issue in the repository, you can follow that thread to get this issue resolved. 
Reply all
Reply to author
Forward
0 new messages