Unsetting a value


#1

Should be an easy one. I want to unset total_budget_amount_local_micro via PUT in the API for a campaign. null doesn’t work, and neither does ‘null’ or 0. Suggestion that I’m overlooking?


#2

Hey Eric,

Setting the param value to the string null should unset the budget (or any other param on a PUT endpoint). Can you share a call that is not resulting in the correct behavior? I was just able to test and get the expected results:

twurl -H ads-api.twitter.com "/0/accounts/18ce53uo8cb/campaigns/1x17x"
{
  "data_type": "campaign",
  "data": {
    "name": "Test campaign",
    "start_time": "2015-11-19T08:00:00Z",
    "reasons_not_servable": [
      "STARTS_IN_FUTURE"
    ],
    "servable": false,
    "daily_budget_amount_local_micro": 15000000000,
    "end_time": null,
    "funding_instrument_id": "i7o2d",
    "standard_delivery": true,
    "total_budget_amount_local_micro": 150000000000,
    "id": "1x17x",
    "paused": false,
    "account_id": "18ce53uo8cb",
    "currency": "USD",
    "created_at": "2014-12-18T17:36:51Z",
    "updated_at": "2015-09-21T21:57:24Z",
    "deleted": false
  },
  "request": {
    "params": {
      "campaign_id": "1x17x",
      "account_id": "18ce53uo8cb"
    }
  }
}
twurl -H ads-api.twitter.com "/0/accounts/18ce53uo8cb/campaigns/1x17x" -X PUT -d "total_budget_amount_local_micro=null"
{
  "data_type": "campaign",
  "data": {
    "name": "Test campaign",
    "start_time": "2015-11-19T08:00:00Z",
    "reasons_not_servable": [
      "STARTS_IN_FUTURE"
    ],
    "servable": false,
    "daily_budget_amount_local_micro": 15000000000,
    "end_time": null,
    "funding_instrument_id": "i7o2d",
    "standard_delivery": true,
    "total_budget_amount_local_micro": null,
    "id": "1x17x",
    "paused": false,
    "account_id": "18ce53uo8cb",
    "currency": "USD",
    "created_at": "2014-12-18T17:36:51Z",
    "updated_at": "2015-09-21T21:57:41Z",
    "deleted": false
  },
  "request": {
    "params": {
      "campaign_id": "1x17x",
      "total_budget_amount_local_micro": "",
      "account_id": "18ce53uo8cb"
    }
  }
}

Jacob


Twitter campaign constraints for PUT calls on budget fields
#3

I had this same issue come up for me today. Although the documentation says that the expected value of total_budget_amount_local_micro is an integer, I tried setting the value in a PUT request to an empty string. This had the desired effect of erasing the total budget limit from the campaign.

The idea to try this came from the following sentences, which I stumbled across on the Getting Started page of the Ads API documentation, in the section HTTP verbs & typical response codes.

When updating data with HTTP PUT, only the specified fields will be updated. You can un-set an optional value by specifying the parameter with an empty string.


#4

This topic was automatically closed after 60 minutes. New replies are no longer allowed.