简体   繁体   English

Android Studio 中的 Github“PUT”请求

[英]Github "PUT" request in Android studio

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();

I'm trying to update the following page of my github account using android studio.我正在尝试使用 android studio 更新我的 github 帐户的以下页面。 This code works for "GET" request but not for "PUT".此代码适用于“GET”请求,但不适用于“PUT”。 My access token works with postman so it should be fine.我的访问令牌与邮递员一起使用,所以应该没问题。 My url link follows the GitHub api guide with the format:我的 url 链接遵循 GitHub api 指南,格式如下:

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

I put the code in an AsyncTask and I do not receive any error from android studio.我将代码放在 AsyncTask 中,但没有收到来自 android studio 的任何错误。 What might be the potential problem?潜在的问题是什么?

Use retrofit with proper annotation.使用带有适当注释的改造。 And debug the code set by step.The you get the problem.并逐步调试设置的代码。你得到了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM