I am trying to use the Reddit API to save a post. I know I am formatting the request wrong, but I can't seem to find any documentation on how to do it correctly. If anyone could either lead me in the right direction, or help me format the request correctly. This is what I have so far.
public void save(View v)
{
OkHttpClient client = new OkHttpClient();
String authString = MainActivity.CLIENT_ID + ":";
String encodedAuthString = Base64.encodeToString(authString.getBytes(),
Base64.NO_WRAP);
System.out.println("myaccesstoken is: "+ myaccesstoken);
System.out.println("the image id is: "+ myimageid);
Request request = new Request.Builder()
.addHeader("User-Agent", "Sample App")
.addHeader("Authorization", "Bearer " + myaccesstoken)
.addHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
.url("https://oauth.reddit.com/api/save.json?")
.post(RequestBody.create(MediaType.parse("application/x-www-form-urlencoded"),
""+ myimageid +
"1"))
.build();
client.newCall(request);
}
I am very very new to using APIs and I am not sure exactly what I am looking for. Here is the link to the reddit API for saving
https://www.reddit.com/dev/api/oauth#POST_api_save
Thank you in advance for any help!!!