Enterprise Device Pins - Fetch
Retrieve all the device pins within a given enterprise in Box.com using SQL Server
- See SQLHTTP easy setup for Box.com
- 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_Box_v2_Enterprise_DevicePins_Fetch( @Profile nvarchar(100), @Marker varchar(50) = NULL, @Limit int = 100, @Direction varchar(4) = 'ASC', @EnterpriseID bigint, @Response nvarchar(MAX) OUTPUT, @StatusCode int OUTPUT, @StatusDescription nvarchar(MAX) OUTPUT) AS DECLARE @URL nvarchar(MAX) DECLARE @QueryString varchar(MAX) DECLARE @HTTPSessionID uniqueidentifier SET @URL = 'https://api.box.com/2.0' EXEC SQLHTTP.net.UrlBuilder @URL OUTPUT, @Profile, 'enterprises', @EnterpriseID, 'device_pinners' EXEC SQLHTTP.net.QueryStringBuilder @QueryString OUTPUT, @URL, 'marker', @Marker, 'limit', @Limit, 'direction', @Direction SET @URL = @URL + @QueryString EXEC SQLHTTP.net.HTTPSession @HTTPSessionID OUTPUT EXEC usp_Box_v2_Auth_Header @Profile, @HTTPSessionID EXEC SQLHTTP.net.HTTPRequest @HttpSessionID, @URL = @URL, @Method = 'GET', @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 |
DECLARE @Response nvarchar(MAX) DECLARE @StatusCode int DECLARE @StatusDescription nvarchar(MAX) DECLARE @Profile nvarchar(100) SET @Profile = 'My Box' --Box.com Oauth2 is token is valid for only one hour EXEC usp_Box_v2_Auth_Refresh @Profile EXEC usp_Box_v2_Enterprise_DevicePins_Fetch @Profile = @Profile, @Marker = '', @EnterpriseID = '18830423', @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') --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/entries[1]/JsonObject' --EXEC SQLHTTP.net.XQueryHelper @X, 'JsonObject' --paging SELECT T.C.value(N'@type', N'nvarchar(MAX)') AS [type] ,T.C.value(N'@id', N'nvarchar(MAX)') AS [id] ,T.C.value(N'@product_name', N'nvarchar(MAX)') AS [product_name] FROM @X.nodes(N'/JsonObject/entries[1]/JsonObject') T(C) --Set @Marker = @Next_Marker --and continue calling the above stored procedure to fetch the next set of entries DECLARE @Next_Marker nvarchar(MAX) SELECT @Next_Marker = T.C.value(N'@next_marker', N'nvarchar(MAX)') FROM @X.nodes(N'/JsonObject') T(C) END |
1 2 3 4 5 6 |
type id product_name --------------- ----------- -------------------- device_pinner 788804 iPad device_pinner 1003086 iPhone |
- Box Content – Search
- Collaboration – Create
- Collaboration – Delete
- Collaboration – Fetch
- Collaboration – Update
- Collection Items – Add or Delete
- Collection Items – Fetch
- Collections – Fetch
- Comment – Create
- Comment – Delete
- Comment – Fetch
- Comment – Update
- Current User – Fetch
- Device Pin – Delete
- Device Pin – Fetch
- Enterprise Device Pins – Fetch
- Enterprise Events – Fetch
- Enterprise Templates – Fetch
- File – Copy
- File – Delete
- File – Download
- File – Lock or Unlock
- File – Upload
- File Collaborations – Fetch
- File Comments – Fetch
- File Embed Link – Fetch
- File Info – Fetch
- File Info – Update
- File Metadata Instance – Create
- File Metadata Instance – Fetch
- File Metadata Instances – Fetch
- File Tasks – Fetch
- File Thumbnail – Fetch
- File Watermark – Fetch
- File Watermark – Remove
- File Watermark – Update
- Folder – Copy
- Folder – Create
- Folder – Delete
- Folder – Fetch
- Folder – Update
- Folder Collaborations – Fetch
- Folder Info – Fetch
- Folder Metadata Instance – Create
- Folder Metadata Instance – Fetch
- Folder Metadata Instances – Fetch
- Folder Watermark – Fetch
- Folder Watermark – Remove
- Folder Watermark – Update
- Group – Create
- Group – Delete
- Group – Fetch
- Group – Update
- Group Membership – Create
- Group Membership – Delete
- Group Membership – Fetch
- Group Membership – Update
- Group Memberships – Fetch
- Groups – Fetch
- Metadata Template – Create
- Metadata Template – Fetch
- Metadata Template – Update
- Pending Collaborations – Fetch
- Recent Items – Fetch
- Task – Create
- Task – Fetch
- Task – Update
- Task Assignment – Create
- Task Assignment – Fetch
- Task Assignment – Update
- Task Assignments – Fetch
- Trashed Item – Delete
- Trashed Item – Fetch
- Trashed Item – Restore
- Trashed Items – Fetch
- User – Create
- User – Fetch
- User – Update
- User Events – Fetch
- User Memberships – Fetch
- Users – Fetch
- Web Link – Create
- Web Link – Delete
- Web Link – Fetch
- Web Link – Update
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.