I was writing the code for uploading image to facebook album "Profile Images", after selecting the image from gallery it is converted to byte array imageBytes
and send to the AsyncTask. I use the fallowing code to upload the image. facebookProfileImagesAlbumId
has the Id for the album "Profile Images"
Bundle params_ = new Bundle();
String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);
params_.putString("source", encodedImage);
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/"+facebookProfileImagesAlbumId+"/photos",
params_,
HttpMethod.POST,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
Log.i("Login", response.toString());
}
}).executeAndWait();
but it is not working and Log.i("Login", response.toString());
gives the following message
{Response: responseCode: 200, graphObject: null, error: {HttpStatus: -1, errorCode: -1, errorType: null, errorMessage: could not construct request body}}
I am using Facebook Graph API 2.4
I have used following code to Post image to facebook wall or specific album.
Hope this helps!