Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Commit 9aa13c6

Browse files
author
Peter Nied
committed
Merge pull request #19 from peternied/master
Adding documentation for Request Options
2 parents 4036b10 + ca75261 commit 9aa13c6

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

docs/overview.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,52 @@ oneDriveClient.getDrive().getItems("1234").buildRequest().expand("thumbnails").g
117117
}
118118
});
119119
```
120+
121+
## Additional request options
122+
123+
If you need to include more specific behavior during a request, there are `Option` objects that you can add when calling `buildRequest`. See a detailed list of query parameters in the [OneDrive API optional query parameters](https://dev.onedrive.com/odata/optional-query-parameters.htm) documentation.
124+
125+
Here's an example of how to add an additional query parameter to sort the returned collection page results by size:
126+
127+
```java
128+
final List<Option> options = new LinkedList<Option>();
129+
options.add(new QueryOption("orderby", "size"));
130+
oneDriveClient
131+
.getDrive()
132+
.getRoot()
133+
.getChildren()
134+
.buildRequest(options)
135+
.get(new ICallback<IItemCollectionPage>() {
136+
@Override
137+
public void success(final IItemCollectionPage iItemCollectionPage) {
138+
// Handle success of this page and its getNextPage() results will have their contents sorted by size
139+
}
140+
@Override
141+
public void failure(final ClientException ex) {
142+
// Handle failure
143+
}
144+
});
145+
```
146+
147+
Here's how to add an additional HTTP header to request only a specific set of bytes from a file (partial download):
148+
149+
```java
150+
final String myItemId = "1234"; // The id of the item to download
151+
final List<Option> options = new LinkedList<Option>();
152+
options.add(new HeaderOption("Range", "bytes=0-128"));
153+
oneDriveClient()
154+
.getDrive()
155+
.getItems(myItemId)
156+
.getContent()
157+
.buildRequest(options)
158+
.get(new ICallback<InputStream>() {
159+
@Override
160+
public void success(final InputStream inputStream) {
161+
// Handle success of this partial range of the file
162+
}
163+
@Override
164+
public void failure(final ClientException ex) {
165+
// Handle failure
166+
}
167+
});
168+
```

0 commit comments

Comments
 (0)