Contact - Create
Create a new Constant Contact contact 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_Contact_Create( @Profile nvarchar(100), @Action_by varchar(20) = NULL, @Body varchar(MAX), @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, 'contacts' EXEC SQLHTTP.net.QueryStringBuilder @QueryString OUTPUT, @Profile, 'action_by', @Action_by, '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 = 'POST', @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 74 75 76 77 78 79 80 81 82 |
DECLARE @Response nvarchar(MAX) DECLARE @StatusCode int DECLARE @StatusDescription nvarchar(MAX) DECLARE @Body varchar(MAX) SET @Body = '{ "addresses": [ { "address_type": "PERSONAL", "city": "Cambridge", "country_code": "US", "line1": "541 Brighton Ave.", "line2": "Unit 785", "line3": "", "postal_code": "01555", "state_code": "MA", "sub_postal_code": "" }, { "address_type": "BUSINESS", "city": "Belleville", "country_code": "CA", "line1": "47 Shawmut Ave.", "line2": "Suite 404", "line3": "", "postal_code": "K8b 5W6", "state_code": "ON" } ], "lists": [ { "id": "1954536638" } ], "cell_phone": "555-555-5555", "company_name": "System Optimzations", "confirmed": false, "email_addresses": [ { "email_address": "username22@example.com" } ], "fax": "555-555-5555", "first_name": "Ronald", "home_phone": "555-555-5555", "job_title": "Systems Analyst 3", "last_name": "Martone", "middle_name": "Angelo", "prefix_name": "Mr.", "work_phone": "555-555-5555" }' EXEC usp_ConstantContact_v2_Contact_Create @Profile = 'My ConstantContact', @Action_by = 'ACTION_BY_OWNER', @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'@status', N'nvarchar(MAX)') AS [status] ,T.C.value(N'email_addresses[1]/JsonObject[1]/@email_address', N'nvarchar(MAX)') AS [email_address] FROM @X.nodes(N'/JsonObject') T(C) END |
1 2 3 4 5 |
id status email_address -------------- ----------- ----------------------- 1502161711 ACTIVE username22@example.com |
- 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.