We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

CTCT exception while updating a schedule

VincentB
Regular Participant

CTCT exception while updating a schedule

Hello, 

 

Am currently building a C # application with the capability of creating and updating schedules for campaigns.

 

When trying to update an existing schedule related to a campaign, am getting the following error: 

"json.type.invalid:#/id: Value is of a disallowed type. Allowed types are: Null, String."

 

This is the code I am using:

// Retrieve the selected schedule

schedule = constantContact.GetSchedule(campaign.Id.ToString(), ScheduleId.ToString());

// get the modified date from the view

if (SendDate != null)
{
schedule.ScheduledDate = DateTime.Parse(SendDate).Date;
}
// update the schedule
constantContact.UpdateSchedule(campaign.Id, schedule);

 

 

I was wondering if I could be further advised in dealing with this issue.

 

Thank You.

5 REPLIES 5
Elijah_G
Member

Hello,

 

I have been looking into this, and it appears that there is an issue in the object definition for the Schedule type. This can be resolved by making a small change in the following file: CTCTWrapper\Components\EmailCampaigns\Schedule.cs on line 21

 

Before:

        public int Id { get; set; }

 

After:

        public string Id { get; set; }

 

Making this change will cause the PUT method to work properly as it will be sending the expected type to the API. It is also worth noting that you code where you used the .ToString() method should no longer be needed, as the id property will not be a string type for campaign schedules.

 

If you are still having any issues after this, please let me know!

 

Sincerely,

Elijah G.
API Support Engineer
VincentB
Regular Participant

Hello Elijah ,

 

Thank you for investigating this issue and providing feedback.

 

I made the change in the CTCTWrapper file and it is not throwing that error anymore.

 

I have a related question. I am trying to modified the scheduled date in 2015 for a schedule.

 

The status of the campaign associated with that schedule is : Scheduled. When i try to modify the scheduked date, it throws the exception:" A schedule resource can only be created for an active campaign that is in Sent or Draft status. "

 

Does this mean, once a schedule is created for a campaign, unless the camnpaign status is one of either Sent or Draft, it cannot be modified?

 

I am attaching a screen cap of myy ap-plication where I try to do the above procedure.

 

Thank You for your time.

 


Const_Contact_UpdateSchedule.JPG

Hello Vincent,

 

I have been looking into this and I have not been able to re-create this behavior when working with schedules on a test campaign. Is it possible for you to place a breakpoint in the HttpRequest method of the RestClient class located in CTCTWrapper/Util/RestClient.cs on line 159? If you can do this, we can capture the request body, as well as related information.

 

I am most interested in the request URL and the data being sent for this PUT request that generates this error for you. If this will not work, the next thing to try is to email us at webservices@constantcontact.com with these details:

- Account Username

- Email Name

- Schedule Time (When the campaign should be sent)

 

That should give us enough information to dig a bit deeper on this issue for you!

 

Sincerely,

Elijah G.
API Support Engineer
VincentB
Regular Participant

Hello Elijah ,

 

I am sorry for the delay, I was put on another project for the past 10 days or so, hence I couldn't address this issue.

 

I tried your suggestion and unfortunately I couldn't find any relevant information to provide you.

 

I will follow your suggestion to email the details to the given email address.

 

Once again, thank you for your time. 

 

Regards,

Vincent

Hi Vincent,

 

After reviewing the information that was sent to me, it turns out this was an issue in the .NET wrapper code. There was a bug causing the wrapper to attempt to create additional schedules instead of updating the existing schedule. This causes the error you were seeing because a campaign can only have one active schedule.

 

The details on how to correct this have been sent in an email reply, and I will be updating our github repository with fixed code in the near future.

 

Best Regards,

Elijah G.
API Support Engineer
Developer Portal

View API documentation, code samples, get your API key.

Visit Page