Hello, I saw a similar post but it didn't help. I'm using the API wrapper with .NET and programming in VB.
When I use the Client.GetCampaigns command it doesn't find any campaigns, even though I have some.
I am able to create new campaigns, delete campaigns, view lists in campaigns, but I cannot get this client control to work. I have a simply button click
<asp:Button runat="server" ID="btnList" Text="List all campaigns" />
Here is the .vb back end:
Imports CampaignMonitorAPIWrapper Imports System Imports System.Collections.Generic Imports System.Text Partial Class _Default Inherits System.Web.UI.Page Protected Sub btnList_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnList.Click Dim apiKey As String = "XXX-My-API-Key-Is-Here-XXX" Dim clientID As String = "XXX-My-ClientID-Is-Here-XXX" Dim result = CampaignMonitorAPIWrapper.Client.GetCampaigns(apiKey, clientID) If result.Code <> 0 Then Response.Write(("Error getting client campaigns : " & result.Code.ToString() & " - ") + result.Message) ElseIf result.ReturnObject.Count = 0 Then Response.Write("There are no campaigns for this client") Else For Each campaign In result.ReturnObject Response.Write("CampaignID : " & campaign.CampaignID) Response.Write("<br />Subject : " & campaign.Subject) Response.Write("<br />Campaign Name : " & campaign.Name) Response.Write("<br />Sent Date : " & campaign.SentDate) Response.Write("<br />Total Recipients : " & campaign.TotalRecipients) Response.Write("<br />---------------------------------------") Next End If End Sub End Class
*The formatting on this forum makes some single line code spill onto two lines
*My API Key and ClientID are correct.
*This campaign is saved as a draft, but I have sent it as a test.
Any help would be appreciated.
I should have added, the code stops once it returns true for the line
ElseIf result.ReturnObject.Count = 0 then
As a result all I get is "There are no campaigns for this client".
So the issue is, why might the count come up as zero when there are campaigns present.
Thanks again :)
Hey andoguy - client.returncampaigns only returns campaigns that have actually been sent; it won't return any that are in draft form. Do you have campaigns for this client that have actually been sent that it's not returning?
That info helps. My campaign was in draft form. I think I'll have to save the list of drafts in a database as I create them then, unless there is any other way to view my drafts using the API?
From Australia to Zimbabwe, and everywhere in between, companies count on Campaign Monitor for email campaigns that drive real business results.Get started for free