GoDoc
Twitter
GitHub
Searchโฆ
Introduction
FAQ
Authentication strategies
Overview
Strategies
Custom Auth
SharePoint client
HTTP Client
Fluent API
Hooks
Retries
Context
Samples
Library Initiation
Basic CRUD
Documents
Chunk upload
Permissions
Groups & Users
Search API
User Profiles
Change API
Attachments
Record Management
Sending Emails
Property Bags
Recycle Bin
Feature management
Advanced item requests
Advanced add/update
Unmarshaling responses
Sandbox
Overview
Utilities
Headers presets
Cpass
Compatibility matrix
Contributing
Overview
Testing
Powered By
GitBook
Recycle Bin
Recycling methods and dealing with recycle bin
You can work with recycle bins via REST API similarly as with lists.
Getting deleted items
1
data
,
err
:=
sp
.
Site
().
RecycleBin
().
2
OrderBy
(
"DeletedDate"
,
false
).
3
Top
(
5
).
4
Get
()
// site's Recycle Bin
5
// data, err := sp.Web().RecycleBin().Get() // web's one
6
if
err
!=
nil
{
7
log
.
Fatal
(
err
)
8
}
9
โ
10
for
_
,
item
:=
range
data
.
Data
()
{
11
d
:=
item
.
Data
()
12
fmt
.
Println
(
13
d
.
ID
,
14
d
.
ItemType
,
15
d
.
LeafNamePath
.
DecodedURL
,
16
d
.
DeletedByName
,
17
d
.
DeletedDate
,
18
)
19
}
Copied!
Items in recycle bins are queryable collection, OData modifiers can be applied in a usual way.
Response is strongly typed, helps do not care about unmarshalling the structures. Items in recycle bin contains the following metadata:
1
type
RecycledItem
struct
{
2
AuthorEmail
string
3
AuthorName
string
4
DeletedByEmail
string
5
DeletedByName
string
6
DeletedDate time
.
Time
7
DeletedDateLocalFormatted
string
8
DirName
string
9
ID
string
10
ItemState
int
11
ItemType
int
12
LeafName
string
13
Size
int
14
Title
string
15
LeafNamePath
*
DecodedURL
16
DirNamePath
*
DecodedURL
17
}
Copied!
Once you have Item ID (which is a GUID in case of recycle bin) you can not resore it.
Restoring recycled items
1
data
,
err
:=
sp
.
Site
().
RecycleBin
().
Top
(
1
).
Get
()
2
if
err
!=
nil
{
3
log
.
Fatal
(
err
)
4
}
5
โ
6
if
len
(
data
.
Data
())
>
0
{
7
itemID
:=
data
.
Data
()[
0
].
Data
().
ID
8
if
err
:=
sp
.
Site
().
RecycleBin
().
GetByID
(
itemID
).
Restore
();
err
!=
nil
{
9
log
.
Fatal
(
err
)
10
}
11
}
Copied!
Samples - Previous
Property Bags
Next - Samples
Feature management
Last modified
2yr ago
Export as PDF
Copy link
Contents
Getting deleted items
Restoring recycled items