Metadata Template - Update
Update a metadata template in a Box.com account 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 |
CREATE PROCEDURE usp_Box_v2_Metadata_Template_Update( @Profile nvarchar(100), @Scope varchar(20), @Template varchar(20), @Body varchar(MAX), @Response nvarchar(MAX) OUTPUT, @StatusCode int OUTPUT, @StatusDescription nvarchar(MAX) OUTPUT) AS DECLARE @URL nvarchar(MAX) DECLARE @HTTPSessionID uniqueidentifier SET @URL = 'https://api.box.com/2.0' EXEC SQLHTTP.net.UrlBuilder @URL OUTPUT, @Profile, 'metadata_templates', @Scope, @Template, 'schema' EXEC SQLHTTP.net.HTTPSession @HTTPSessionID OUTPUT EXEC usp_Box_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 |
DECLARE @Response nvarchar(MAX) DECLARE @StatusCode int DECLARE @StatusDescription nvarchar(MAX) DECLARE @Body varchar(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 SET @Body = '[ { "op":"editField", "fieldKey":"category", "data":{ "displayName":"Customer Group" } }]' EXEC usp_Box_v2_Metadata_Template_Update @Profile = @Profile, @Scope = 'enterprise', @Template = 'customer', @Body = @Body, @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' SELECT T.C.value(N'@templateKey', N'nvarchar(MAX)') AS [templateKey] ,T.C.value(N'@scope', N'nvarchar(MAX)') AS [scope] ,T.C.value(N'@displayName', N'nvarchar(MAX)') AS [displayName] ,T.C.value(N'fields[1]/JsonObject[2]/@key', N'nvarchar(MAX)') AS [fields_key] ,T.C.value(N'fields[1]/JsonObject[2]/@displayName', N'nvarchar(MAX)') AS [fields_displayName] FROM @X.nodes(N'/JsonObject') T(C) END |
1 2 3 4 5 6 |
templateKey scope displayName fields_key fields_displayName ------------ -------------------- ------------ ------------- ------------------ customer enterprise_18830423 Customer category Customer Group |
- 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.