Community Discussion

Ask a Question
Back to All

Java Backstage SDK - Update Campaign Item fails

I'm trying to toggle a campaign item's active status, however it returns with a 400 error:

Exception in thread "main" com.taboola.backstage.exceptions.BackstageAPIRequestException: Failed to perform API call with response code [400]. Response payload status [400], message [Unknown field name 'active'], offending field [null], message code [api.action.bad_request.null]
    at com.taboola.backstage.internal.SynchronousCallAdapterFactory$1.adapt(
    at retrofit2.HttpServiceMethod$CallAdapted.adapt(
    at retrofit2.HttpServiceMethod.invoke(
    at retrofit2.Retrofit$1.invoke(
    at com.sun.proxy.$Proxy3.updateItem(Unknown Source)

My code is pretty simple (vars spoofed)...

        Backstage backstage = Backstage.builder().build();
        String accountName = "account123456";
        String campaignId = "123456";
        String itemId = "987654321";
        CampaignItem item = backstage.campaignItemsService().readItem(clientAuth, accountName, campaignId, itemId);"ID:{}  active:{}  status:{}  name:{}", item.getId(), item.getActive(), item.getStatus(), item.getTitle());

        // Update status to opposite
        CampaignItemOperation operation = CampaignItemOperation.create().setActive(!item.getActive());
        CampaignItem updatedItem = backstage.campaignItemsService().updateItem(clientAuth, accountName, campaignId, itemId, operation);

The code fails on the last line, with the above exception. Any ideas what I'm doing wrong?

As you can see, I'm able to retrieve the Campaign Item just not update its active value.