This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Working with List in SendGrid

 Overview

OperationDescription
addListCreate a new Recipient List.
editListRename a Recipient List.
getListList all Recipient Lists on your account, or check if a particular List exists.
deleteListRemove a Recipient List from your account.

Operation details

This section provides details on the operations.

Adding new list

The addList operation adds a Recipient List in your account.

addList
   <sendgrid.addList>
       <list>{$ctx:list}</list>
       <name>{$ctx:name}</name>
   </sendgrid.addList>

Properties

list : Required - Create a Recipient List with this name.

name: Specify the column name for the name associated with email addresses. 

Sample Request for addList
 {
  "apiUrl":"https://api.sendgrid.com/api/newsletter",
  "apiUser":"UserName",
  "apiKey":"PassWord",
  "list":"test"
}

Editing a list

The editList operation rename a Recipient List.

editList
   <sendgrid.editList>
       <list>{$ctx:list}</list>
       <newlist>{$ctx:newlist}</newlist>
   </sendgrid.editList>

Properties

list : Required - This is the name of the Recipient List to be renamed.

newlist: Required - Specify the new name for the Recipient List. 

Sample Request for editList
 {
  "apiUrl":"https://api.sendgrid.com/api/newsletter",
  "apiUser":"UserName",
  "apiKey":"PassWord",
  "list":"test",
  "newlist":"newtest"
}

Getting a list

The getList operation gets all Recipient List.

getList
<sendgrid.getList>
    <list>{$ctx:list}</list>
</sendgrid.getList>

Properties

list :  Check for this particular list.

 

Sample Request for getList
{
  "apiUrl":"https://api.sendgrid.com/api/newsletter",
  "apiUser":"UserName",
  "apiKey":"PassWord",
  "list":"test"
}

Deleting a list

The   deleteList operation removes a Recipient List from your account.

deleteList
<sendgrid.deleteList>
    <list>{$ctx:list}</list>
</sendgrid.deleteList>

Properties

list :  Required - Remove this Recipient List.

 

Sample Request for deleteList
{
  "apiUrl":"https://api.sendgrid.com/api/newsletter",
  "apiUser":"UserName",
  "apiKey":"PassWord",
  "list":"test"
}

Sample configuration

Following is a sample proxy service that illustrates how to connect to SendGrid with the init operation and use the addList operation. You can use this sample as a template for using other operations in this category.

Sample Proxy
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="sendgrid_addList"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
    <target>
        <inSequence>
            <property name="apiUrl" expression="json-eval($.apiUrl)"/>
            <property name="apiUser" expression="json-eval($.apiUser)"/>
            <property name="apiKey" expression="json-eval($.apiKey)"/>
			<property name="list" expression="json-eval($.list)"/>
			<property name="name" expression="json-eval($.name)"/>
 			<sendgrid.init>
    			<apiUrl>{$ctx:apiUrl}</apiUrl>
    			<apiUser>{$ctx:apiUser}</apiUser>
    			<apiKey>{$ctx:apiKey}</apiKey>
			</sendgrid.init>

			<sendgrid.addList>
    			<list>{$ctx:list}</list>
    			<name>{$ctx:name}</name>
			</sendgrid.addList>
   
           <respond/>
        </inSequence>
        <outSequence>
            <log/>
            <send/>
        </outSequence>
    </target>
    <description/>
</proxy>