In a previous post, we showed you how to Create and Manage Emails using the REST API.

In today's post we'll show you how to Create and Manage Landing Pages.

 

We'll be using the following operations :

  • Retrieve a Landing Page
  • Search for Landing Pages
  • Create a Page
  • Update a Page
  • Delete a Page

 

The code assumes that you've initialized the REST client. Please see the following post on making Eloqua REST API - C# requests.

The complete source code for the examples shared here is available here on Github.

The models are available here.

 

Retrieve a Landing Page

Let's start by retrieving a Landing Page from your install.

Note that this method assumes that you know the ID of a Landing Page in your install. If you're not sure of this, skip to Searching for Landing Pages.

 

public LandingPage GetLandingPage (int id)
        {
            RestRequest request = new RestRequest(Method.GET)
                                      {
                                          RequestFormat = DataFormat.Json,
                                          Resource = "/assets/landingPage/" + id
                                      };

            IRestResponse<LandingPage> response = _client.Execute<LandingPage>(request);
            return response.Data;
}
  

 

Searching for Landing Pages

The Search operation takes 3 arguments :

  • searchTerm : specifies the search criteria to use to filter the Landing Pages
  • page : the page of entities to return
  • pageSize : the number of entities to return

 

publicList<LandingPage> GetLandingPages (string searchTerm, int page, int pageSize)
        {
            RestRequest request = new RestRequest(Method.GET)
                                      {
                                          RequestFormat = DataFormat.Json,
                                          Resource =
                                              string.Format("/assets/landingPages?search={0}&page={1}&count={2}",
                                                            searchTerm, page, pageSize)
                                      };

            IRestResponse<RequestObjectList<LandingPage>> response =
                _client.Execute<RequestObjectList<LandingPage>>(request);

            Console.WriteLine("Total : " + response.Data.elements.Count);

            return response.Data.elements;
}
 

 

Creating a Landing Page

Now let's create a new Landing Page. We'll start by creating the definition for a new Landing Page object :

 

LandingPagelandingPage = newLandingPage
                                          {
                                              name = "sample landing page",
                                              htmlContent = new RawHtmlContent
                                                                {
                                                                    type = "RawHtmlContent",
                                                                    html =
                                                                        "<html><head></head><body>Sample Landing Page</body></html>"
                                                                }
                                          };
            LandingPage returnedLandingPage = _landingPageHelper.CreateLandingPage(landingPage);
Assert.AreEqual(landingPage.name,returnedLandingPage.name);
 

 

Next, we'll provide a function that invokes an HTTP POST request to create the page :

 

public LandingPage CreateLandingPage(LandingPage landingPage)
        {
            RestRequest request = new RestRequest(Method.POST)
                                      {
                                          Resource = "/assets/landingPage",
                                          RequestFormat = DataFormat.Json
                                      };
            request.AddBody(landingPage);

            IRestResponse<LandingPage> response = _client.Execute<LandingPage>(request);

            return response.Data;
}

 

The code samples on Github contain methods and examples for :

  • Updating your Page
  • Deleting your Page

 

Please note that the REST API is not yet public and the code samples available here are my own work. I'll be glad to help support and fix issues in the code, but please understand that Eloqua will not be able to support this - as it is my own.

 

Thanks,
Fred