Forms - Fetch
Retrieve Gravity Forms using SQL Server
- See SQLHTTP easy setup for Gravity Forms
- 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 46 47 48 49 50 51 52 |
CREATE PROCEDURE usp_GravityForms_Forms_Fetch( @Profile nvarchar(100), @Response nvarchar(MAX) OUTPUT, @StatusCode int OUTPUT, @StatusDescription nvarchar(MAX) OUTPUT) AS DECLARE @URL nvarchar(MAX) DECLARE @QueryString nvarchar(MAX) DECLARE @HTTPSessionID uniqueidentifier DECLARE @Path nvarchar(MAX) DECLARE @PublicKey nvarchar(100) DECLARE @UNIXTime bigint DECLARE @Signature varchar(100) SET @URL = SQLHTTP.net.AuthParam(@Profile, 'RootURL') SET @Path = N'forms' COLLATE SQL_Latin1_General_CP1_CI_AS EXEC usp_GravityForms_AuthParameters @Profile = @Profile, @Method = 'GET', @Path = @Path, @PublicKey = @PublicKey OUTPUT, @UNIXTime = @UNIXTime OUTPUT, @Signature = @Signature OUTPUT SET @URL = @URL + N'/gravityformsapi/' COLLATE SQL_Latin1_General_CP1_CI_AS + @Path EXEC SQLHTTP.net.QueryStringBuilder @QueryString OUTPUT, @Profile, 'api_key', @PublicKey, 'expires', @UNIXTime SET @URL = @URL + @QueryString + '&signature=' COLLATE SQL_Latin1_General_CP1_CI_AS + @Signature EXEC SQLHTTP.net.HttpSession @HttpSessionID OUTPUT EXEC SQLHTTP.net.HttpRequest @HttpSessionID, @URL = @URL, @AllowAutoRedirect = 1, @Response = @Response OUTPUT, @StatusCode = @StatusCode OUTPUT, @StatusDescription = @StatusDescription 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 |
DECLARE @Response nvarchar(MAX) DECLARE @StatusCode int DECLARE @StatusDescription nvarchar(MAX) EXEC usp_GravityForms_Forms_Fetch @Profile = 'My GravityForms', @Response = @Response OUTPUT, @StatusCode = @StatusCode OUTPUT, @StatusDescription = @StatusDescription OUTPUT IF @StatusCode >= 400 EXEC SQLHTTP.net.RaiseHttpError @StatusCode, @StatusDescription, @Response ELSE BEGIN DECLARE @X xml SET @X = SQLHTTP.net.Json_To_XML(@Response, '0') WHILE EXISTS( SELECT * FROM SQLHTTP.net.MidTexts(CONVERT(nvarchar(MAX), @X), '_x', '_')) BEGIN SET @X = CONVERT(xml, REPLACE(CONVERT(nvarchar(MAX), @X), '_x' + SQLHTTP.net.MidText(CONVERT(nvarchar(MAX), @X), '_x', '_', 1) + '_', 'Form')) END ----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/response/Form' -- SELECT T.C.value(N'@id', N'nvarchar(MAX)') AS id ,T.C.value(N'@entries', N'nvarchar(MAX)') AS entries ,T.C.value(N'@title', N'nvarchar(MAX)') AS title FROM @X.nodes(N'/JsonObject/response/Form') T(C) END |
1 2 3 4 5 6 |
id entries title ----- --------- ------------------------ 1 234 Contact Us 2 5 Support |
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.