Hello I’m Attempting to post a video to Twitter using the https://media.twitter.com/1.1/media/upload.json endpoint using fabric’s extensible endpoint example found here. I’ve modified the client to use the parameters from the chunked uploads REST service and when I attempted to do the INIT call, it now returns com.twitter.sdk.android.core.TwitterApiException: 404 Not Found.
Here is the code to my custom API Service:
public class TwitterVideoAPI extends TwitterApiClient {
public TwitterVideoAPI(TwitterSession session) {
super(session);
}
public TwitterVideoAPIServiceInit initUploadVideo() {
return getService(TwitterVideoAPIServiceInit.class);
}
public TwitterVideoAPIServiceAppend appendUploadVideo() {
return getService(TwitterVideoAPIServiceAppend.class);
}
public TwitterVideoAPIServiceFinalize finalizeUploadVideo() {
return getService(TwitterVideoAPIServiceFinalize.class);
}
public interface TwitterVideoAPIServiceInit {
@FormUrlEncoded()
@POST("/1.1/media/upload.json")
void initialize(@Field("command") String command,
@Field("total_bytes") String totalBytes,
@Field("media_type") String mediaType,
Callback <Twitter> callback);
}
public interface TwitterVideoAPIServiceAppend {
@Multipart
@POST("/1.1/media/upload.json")
void append(@Part("command") String command,
@Part("media_id") String mediaId,
@Part("media") TypedFile media, // The raw binary file content being uploaded. Cannot be used with media_data.
// Required after an INIT, an index number starting at zero indicating the order of the uploaded chunks.
// The chunk of the upload for a single media, from 0-999, inclusive.
// The first segment_index is 0, the second segment uploaded is 1, etc.
@Part("segment_index") int segmentIndex,
Callback <Twitter> callback);
}
public interface TwitterVideoAPIServiceFinalize {
@POST("/1.1/media/upload.json")
@FormUrlEncoded()
void finalize(@Field("command") String command,
@Field("media_id") String mediaId,
Callback <Twitter> callback);
}
Here is how I’m calling the custom service for INIT:
TwitterCore.getInstance().getFabric().setCurrentActivity(this);
TwitterVideoAPI videoUpload = new TwitterVideoAPI(session);
TwitterVideoAPI.TwitterVideoAPIServiceInit init = videoUpload.initUploadVideo();
init.initialize("INIT", String.valueOf(video.length()), "video%2Fmp4", new Callback<Twitter>() {
@Override
public void success(Result result) {
Log.e("INIT_SUCCESS", result.toString());
}
@Override
public void failure(TwitterException e) {
Log.e("INIT_FAILURE", e.toString() + " - " + e.getMessage());
}
});
Any help or pointers on how to get this working properly would be greatly appreciated, as I am having a hard time with this API call.