I have a managing account with a credit line. I'm creating new managed accounts and add budgets through the service BudgetOrderService. All worked fine but about a month ago I started to get an error:
Request made: Service: BudgetOrderService Method: mutate clientCustomerId: 111111111 URL: https://adwords.google.com/api/adwords/billing/v201806/BudgetOrderService Request ID: 00056f9cb9ada6e00ac103417802ae84 ResponseTime(ms): 77 OperationsCount: 1 IsFault: true FaultMessage: ApiException{applicationExceptionType=ApiException, errors=[BudgetOrderError{apiErrorType=BudgetOrderError, errorString=BudgetOrderError.INVALID_BILLING_ACCOUNT, fieldPath=operations[0].operand, fieldPathElements=[FieldPathElement{field=operations, index=0}, FieldPathElement{field=operand}], reason=INVALID_BILLING_ACCOUNT, trigger=}]}
That's weird because I get billing account just before adding a budget order. Just as documented in Adwords documentation. And it worked. And I still can add a budget order manually through adwords web interface. Also creating a budget order still works for my older managed accounts which already had budget orders.
The code:
val billingAccount = budgetOrderService.getBillingAccounts.head
val budgetOrder = new BudgetOrder
budgetOrder.setBillingAccountId(billingAccount.getId)
budgetOrder.setPrimaryBillingId(billingAccount.getPrimaryBillingId)
budgetOrder.setStartDateTime(Adwords.formatDateTime(DateTime.now.plusMinutes(5)))
budgetOrder.setEndDateTime("20350118 181818 Europe/Moscow")
budgetOrder.setSpendingLimit(new cm.Money(null, balance * 10000))
val op = new BudgetOrderOperation
op.setOperator(Operator.ADD)
op.setOperand(budgetOrder)
val response = budgetOrderService.mutate(Array(op))