Twitter campaign constraints for PUT calls on budget fields


#1

I have read several pages on how to unset fields via PUT api calls. The Twitter Ads API documentation says to pass an empty string.

We are finding that we can’t unset the daily_budget_amount_local_micro on a twitter campaign via a PUT call. The sample request and response are shown below:

  curl --request 'PUT' \
'https://ads-api.twitter.com/1/accounts/<account_id>/campaigns/<campaign_id>' \
--data 'daily_budget_amount_local_micro=' --header 'Authorization: OAuth \
oauth_consumer_key="<value>", oauth_nonce="<value>", \
oauth_signature="<value>", \
oauth_signature_method="HMAC-SHA1", \
oauth_timestamp="1473719906", oauth_token="<value>", \
oauth_version="1.0"' --verbose

 {"errors":[{"code":"INVALID_PARAMETER",
"message":"Expected Long, got \"\" for daily_budget_amount_local_micro",
"parameter":"daily_budget_amount_local_micro"}],
"request":{"params":{"campaign_id":"<the campaign id>",
"account_id":"< the account id>"}}}

Here are the settings for the campaign that we’re using, minus the Ids:

{"request":{"params":{"campaign_id":"<campaign id>",
"account_id":"<account id>"}},
"data_type":"campaign",
"data":{"name":"Mon Sep 12 2016 18:38:42 GMT-0400 (EDT)102219",
"start_time":"2016-09-13T22:38:42Z",
"reasons_not_servable":["PAUSED_BY_ADVERTISER"],
"servable":false,
"daily_budget_amount_local_micro":5000000,
"end_time":null,
"funding_instrument_id":"<funding instrument id>",
"duration_in_days":null,
"standard_delivery":true,
"total_budget_amount_local_micro":null,
"id":"<campaign_id>",
"paused":true,
"account_id":"<account_id>",
"frequency_cap":null,
"currency":"USD",
"created_at":"2016-08-03T19:16:58Z",
"updated_at":"2016-09-12T22:38:43Z",
"deleted":false}}

Is there an undocumented restriction on unsetting daily_budget_amount_local_micro? Maybe, it can’t be unset if total_budget_amount_local_micro is null?


#2

Hi, @chris_august7. Does this happen for other parameters? This may be due to the fact that daily_budget_amount_local_micro is a required param. Have you tried changing this value instead of trying to unset it?


#3

Ah. The documentation for PUT says its “optional” because its optional to change the value you’ve set. The field itself is required (as explained in the POST documentation).

That makes sense. In this case, it would be nice if the error handling were clearer, but this is basically just user error on our part. Thanks!


#4

Thanks for confirming so quickly, @chris_august7. Glad this is cleared up now.

Also, the following is a good way to describe this for the PUT accounts/:account_id/campaigns/:campaign_id endpoint:

[It’s] “optional” because it’s optional to change the value you’ve set.

:+1: