Reputation: 146
Does anyone know how to use Skydrive REST API in Android?
(documented here http://msdn.microsoft.com/de-de/library/live/hh243648.aspx)
All Data that are needed for access are already stored!
private String AccessToken;
private String AuthenticationToken;
private String RefreshToken;
private String ExpiresIn;
private String Scope;
Is it right to use
HttpClient client = new DefaultHttpClient();
Does anyone have a full example?
Any ideas or suggestion would be helpful. Thank you.
Upvotes: 3
Views: 1630
Reputation: 3022
You can do something like this.
InputStream result = null;
HttpClient httpClient = new DefaultHttpClient();
HttpGet get = new HttpGet("https://apis.live.net/v5.0/me/albums?access_token=" + AccessToken); // For example
HttpResponse response = httpClient.execute(get);
if (response != null && response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
BufferedHttpEntity bufferedHttpEntity = new BufferedHttpEntity(response.getEntity());
result = bufferedHttpEntity.getContent();
} else {
// insert error handling
}
Depending on what request you are making you may need to use HttpPut
, HttpPost
, HttpDelete
, etc. instead of HttpGet
.
- GET - Returns the representation of a resource.
- POST - Adds a new resource to a collection.
- PUT - Updated to the location that was specified as the target URL, or add a resource there, add a resource if one does not exist.
- DELETE - Deletes a resource.
If the request requires a body, you can add it with setEntity()
which takes an HttpEntity object.
Upvotes: 1