Community Discussion
Java Backstage SDK - Update Campaign Item fails
almost 4 years ago by Colin MacLean
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(SynchronousCallAdapterFactory.java:70)
at retrofit2.HttpServiceMethod$CallAdapted.adapt(HttpServiceMethod.java:165)
at retrofit2.HttpServiceMethod.invoke(HttpServiceMethod.java:146)
at retrofit2.Retrofit$1.invoke(Retrofit.java:160)
at com.sun.proxy.$Proxy3.updateItem(Unknown Source)
at com.taboola.backstage.services.CampaignItemsServiceImpl.updateItem(CampaignItemsServiceImpl.java:87)
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);
logger.info("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.