Campaign update from the API - Error changing several fields?

Hi everyone,

We have an error when we try to update a campaign status using the API.
We get a message saying the we are trying to modify other fields than the status at the same time.
After checking our code, we only modify the status.

Does anyone has an explanation to this issue ?

Below the error we get :

"status":400,
"code":"invalid.update",
"message":"An attempt was made to update a Campaign in an invalid way. Details: A campaign cannot have other fields changed in the same update as a status change",
"messageWithParams":"An attempt was made to update a {entity} in an invalid way. Details: {INVALID_UPDATE}",
"messageParams":{"INVALID_UPDATE":"A campaign cannot have other fields changed in the same update as a status change","entity":"Campaign"},
"contextId":"f03592ec-e1a1-4fa5-be37-43675741886c",
"details":[],
"errors":[]

Thanks a lot for your help.

Baptiste.

Hi Baptiste, what endpoint were you using specifically, and what was the HTTP method and payload?

Can you provide a code example showing how you're invoking the SDK? From that context ID it looks like you're using the Java SDK.

Hi,

We don't use an specific endpoint as we use Java SDK from Purecloud: platform-client-v2-7.1.2.jar

The API used is OutboundApi and the method is putOutboundCampaign(String campaignId, Campaign campaign) where campaign is an object previously recovered from Purecloud with method getOutboundCampaign(String campaignId) (also from API OutboundApi).

We only change status of this object as here: campaign.setCampaignStatus("on")

Then putOutboundCampaign method returns us this error.

Thanks a lot for your help.
Baptiste.

This error is probably being caused by you sending a campaign object that's populated with data. When you send a PUT request, it's going to look at everything in the body and use those values to make changes. Try creating a new Campaign object and only setting the status and send that as the body.

Just an FYI, OutboundApi.putOutboundCampaign(...) is making an API request to PUT /api/v2/outbound/campaigns/{campaignId}. The purpose of the SDK is to assist the developer in making the HTTPS requests to the API; its functionality exactly mirrors the API contracts.

Hello Tim, I tried it but it doesn't work because if I set only the status, the error is:

{"status":400,"code":"bad.request","message":"Name is required.","details":[],"errors":[]}

And if I add name value then, the error is:

{"status":400,"code":"invalid.update","message":"An attempt was made to update a Campaign in an invalid way. Details: A campaign cannot have other fields changed in the same update as a status change","messageWithParams":"An attempt was made to update a {entity} in an invalid way. Details: {INVALID_UPDATE}","messageParams":{"INVALID_UPDATE":"A campaign cannot have other fields changed in the same update as a status change","entity":"Campaign"},"contextId":"b6bf72e7-03b7-40e9-b552-53090f55e6cc","details":[],"errors":[]}

Thanks in advance.

Hello Tim,

Could it be due to any campaign configuration complexity, for instance : rulesets, filter, recycling ?

Thanks for your help.

Baptiste.

My apologies, my previous response was incorrect. This is a PUT, not a PATCH, and therefore requires the full request body. I have verified that this works correctly using the SDK with the following code. Be sure that you don't change anything other than the status or you'll get that error.

OutboundApi outboundApi = new OutboundApi();
String campaignId = "7fc6b00a-f2f5-44d2-9fc5-169f339f6c4b";

Campaign campaign = outboundApi.getOutboundCampaign(campaignId);
campaign.setCampaignStatus("on");

ApiResponse<Campaign> result = outboundApi.putOutboundCampaignWithHttpInfo(campaignId, campaign);
System.out.println(result.getStatusCode());
System.out.println(result.getBody());

Hello again,

It didn't work either. Same error but with different context id:

{"status":400,"code":"invalid.update","message":"An attempt was made to update a Campaign in an invalid way. Details: A campaign cannot have other fields changed in the same update as a status change","messageWithParams":"An attempt was made to update a {entity} in an invalid way. Details: {INVALID_UPDATE}","messageParams":{"INVALID_UPDATE":"A campaign cannot have other fields changed in the same update as a status change","entity":"Campaign"},"contextId":"0511c9e4-a1ba-4834-8e35-6e20945bbc5c","details":[],"errors":[]}

Hi
We get this same issue on one project. We use C# API. I share this link with end user dev team (they provide solution them-self). We think that it occurs because we use Filters in campaign configuration.

Regards Rafal

Probably our issue disappear when we use PureCloudPlatform.Client.V2.Model insted first version. Now we test it.

Maybe this same you have in Java API

Regards.

Thank you for your answer.

Maybe not, because we are using PureCloudPlatform.Client.V2.Model throught SDK in Java, and we have this issue.

To try and eliminate the SDK as the cause, can you try this using the Developer Tools API Explorer? Try getting the campaign object, copy the response body, paste it into the PUT request, and update only the status property.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.