Email-Marketing Campaign - Update
Update an existing Constant Contact email marketing campaign using SQL Server
- See SQLHTTP easy setup for Constant Contact
- See API Call documentation for parameter values and other information
- Create the stored procedure documented below
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
CREATE PROCEDURE usp_ConstantContact_v2_EmailMarketingCampaign_Update( @Profile nvarchar(100), @Body varchar(MAX), @CampaignID bigint, @Response nvarchar(MAX) OUTPUT, @StatusCode int OUTPUT, @StatusDescription nvarchar(MAX) OUTPUT) AS SET NOCOUNT ON DECLARE @URL varchar(MAX) DECLARE @QueryString varchar(MAX) DECLARE @HTTPSessionID uniqueidentifier SET @URL = 'https://api.constantcontact.com/v2' EXEC SQLHTTP.net.UrlBuilder @URL OUTPUT, @Profile, 'emailmarketing', 'campaigns',@CampaignID EXEC SQLHTTP.net.QueryStringBuilder @QueryString OUTPUT, @Profile, 'api_key', '#APIKey' SET @URL = @URL + @QueryString EXEC SQLHTTP.net.HTTPSession @HTTPSessionID OUTPUT EXEC usp_ConstantContact_v2_Auth_Header @Profile, @HTTPSessionID EXEC SQLHTTP.net.HTTPRequest @HttpSessionID, @URL = @URL, @Method = 'PUT', @Body = @Body, @ContentType = 'application/json', @StatusCode = @StatusCode OUTPUT, @StatusDescription = @StatusDescription OUTPUT, @Response = @Response OUTPUT GO |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
DECLARE @Response nvarchar(MAX) DECLARE @StatusCode int DECLARE @StatusDescription nvarchar(MAX) DECLARE @Body varchar(MAX) SET @Body = '{ "name": "Test Campaign 1356675725", "subject": " Special offers for a week", "from_name": "My Organization", "from_email": "from-email@example.com", "reply_to_email": "reply-to-email@example.com", "status": "DRAFT", "is_permission_reminder_enabled": true, "permission_reminder_text": "Hi, just a reminder that you are receiving this email because you have expressed an interest in MyCompany.", "is_view_as_webpage_enabled": true, "view_as_web_page_text": "Having trouble viewing this message?", "view_as_web_page_link_text": "Click here to view as a Web page", "greeting_salutations": "Hello", "greeting_name": "FIRST_NAME", "greeting_string": "Dear ", "email_content": "<html><body><p>This is text of the email message.</p></body></html>", "text_content": "This is the text of the email", "email_content_format": "HTML", "style_sheet": "", "message_footer": { "organization_name": "Your Organization", "address_line_1": "123 Maple Street", "address_line_2": "Unit 1", "address_line_3": "", "city": "Anytown", "state": "MA", "international_state": "", "postal_code": "01444", "country": "US", "include_forward_email": true, "forward_email_link_text": "Forward this message to a friend!", "include_subscribe_link": true, "subscribe_link_text": "Sign up for our mailing list!" } }' EXEC usp_ConstantContact_v2_EmailMarketingCampaign_Update @Profile = 'My ConstantContact', @CampaignID = '1127805179665', @Body = @Body, @Response = @Response OUTPUT, @StatusCode = @StatusCode OUTPUT, @StatusDescription = @StatusDescription OUTPUT IF @StatusCode >= 400 --An HTTP Request error has occured EXEC SQLHTTP.net.RaiseHttpError @StatusCode, @StatusDescription, @Response ELSE BEGIN DECLARE @X xml SET @X = SQLHTTP.net.Json_To_Xml(@Response, '0') --The XPath syntax below was easily generated by executing the following commands: --EXEC SQLHTTP.net.XQueryHelper @X --and then executing: --EXEC SQLHTTP.net.XQueryHelper @X, 'JsonObject' SELECT T.C.value(N'@id', N'nvarchar(MAX)') AS [id] ,T.C.value(N'@name', N'nvarchar(MAX)') AS [name] ,T.C.value(N'@subject', N'nvarchar(MAX)') AS [subject] ,T.C.value(N'message_footer[1]/@organization_name', N'nvarchar(MAX)') AS [organization_name] FROM @X.nodes(N'/JsonObject') T(C) END |
1 2 3 4 5 6 7 |
id name subject organization_name -------------- ------------------------ ---------------------------- ------------------ 1127805179665 Test Campaign 1356675725 Special offers for a week Your Organization |
- Account Info – Fetch
- Account Info – Update
- Account Verified-Email-Address – Create
- Account Verified-Email-Addresses – Fetch
- Contact – Create
- Contact – Fetch
- Contact – Unsubscribe
- Contact List – Create
- Contact List – Delete
- Contact List – Fetch
- Contact List – Update
- Contact Lists – Fetch
- Contacts – Fetch
- Email-Marketing Campaign – Create
- Email-Marketing Campaign – Delete
- Email-Marketing Campaign – Fetch
- Email-Marketing Campaign – Preview
- Email-Marketing Campaign – Update
- Email-Marketing Campaign Schedule – Create
- Email-Marketing Campaign Test – Create
- Email-Marketing Campaigns – Fetch
- Event – Create
- Event – Fetch
- Event – Patch
- Event – Update
- Event Fee – Create
- Event Fee – Delete
- Event Fee – Fetch
- Event Fee – Update
- Event Fees – Fetch
- Event Item – Create
- Event Item – Delete
- Event Item – Fetch
- Event Item – Update
- Event Item Attribute – Create
- Event Item Attribute – Delete
- Event Item Attribute – Fetch
- Event Item Attribute – Update
- Event Item Attributes – Fetch
- Event Items – Fetch
- Event Promocode – Create
- Event Promocode – Delete
- Event Promocode – Fetch
- Event Promocode – Update
- Event Promocodes – Fetch
- Event Registrant – Fetch
- Event Registrants – Fetch
- Events – Fetch
- Library File – Delete
- Library File Upload-Status – Fetch
- Library Files – Move
- Library Folder – Create
- Library Folder – Delete
- Library Folder – Fetch
- Library Folder – Update
- Library Folders Trash Files – Delete
- Library Info – Fetch
IMPORTANT DISCLAIMER
CODE/SQL ON THESE PAGES ARE PROVIDED AS-IS AND ARE AVAILABLE FOR ILLUSTRATIVE PURPOSES ONLY.
USERS ARE REQUIRED TO ABIDE BY THE TERMS AND CONDITIONS FOR USING REFERENCED THIRD PARTY WEBSITES AND/OR APIs FROM THEIR RESPECTIVE WEBSITES. WE DO NOT CONDONE ANY VIOLATION OF THIRD PARTY WEBSITES AND/OR APIs TERMS AND CONDITIONS USING OUR SOFTWARE.
USERS SHALL BE SOLELY RESPONSIBLE AND BE SOLELY LIABLE FOR VIOLATION OF ANY RULES SPECIFIED BY THIRD PARTIES FOR USING THEIR WEBSITES AND/OR APIs, OR INFRINGEMENT OF RIGHTS OF SUCH THIRD PARTIES.