android - Android studio 中的 Github "PUT"请求

标签 android android-studio github android-asynctask github-api

URL url = new URL(link);
connection1 = (HttpsURLConnection) url.openConnection();
String auth = username + ":" + access_token;
String token = "Basic " + (Base64.encodeToString(auth.getBytes(), Base64.NO_WRAP));
connection1.setRequestProperty("Content-Length", "0");
connection1.setRequestMethod("PUT");
connection1.setRequestProperty("Authorization", token);
connection1.setDoOutput(true);
connection1.connect();

我正在尝试使用 android studio 更新我的 github 帐户的以下页面。此代码适用于“GET”请求但不适用于“PUT”。我的访问 token 与 postman 一起使用,所以应该没问题。我的 url 链接遵循 GitHub api 指南,格式为:

https://api.github.com/user/following/user_to_follow

我将代码放在 AsyncTask 中,但我没有收到来自 android studio 的任何错误。潜在的问题是什么?

最佳答案

使用带有适当注释的改造。并逐步调试设置的代码。你得到了问题。

关于android - Android studio 中的 Github "PUT"请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47009632/

相关文章:

java - 如何在 Java Android 中共享/导出 JSON 文件

git-tfs 本地 Git repo 到 TFVC

Android string.xml 和 xmlstarlet

android - 为什么将 Activity 实例保存到静态单例中不起作用?

Android - Google API - 检测 SDK 时出错

java - set_timerslack_ns写入失败: Operation not permitted. Android MapFragment

git:检测 github PR squash 是否为空操作

git - 当我们目前拥有开发和生产服务器时,我们如何开始使用 git?

java - 按下键后如何控制edittext中的文本?

java - Android:Edittext 只允许 1-9 的数字