https://qiita.com/yamikoo@github/items/7bcfdf7f154f37c07e0d
上記サイトを参考に画像をポストする処理を描いたのですが
OutputStream os = connection.getOutputStream();
の箇所でエラーが発生してしまいます。
W/System.err: java.net.ProtocolException: cannot write request body after response has been read W/System.err: at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:264) W/System.err: at com.example.ss.w.ServManage$BitMapPost.doInBackground(ServManage.java:281) W/System.err: at com.example.ss.w.ServManage$BitMapPost.doInBackground(ServManage.java:246) W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:333) W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:266) W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) W/System.err: at java.lang.Thread.run(Thread.java:764)
返り値はNullとなります。
試しにPost先のPHPを
<?PHP echo "test"; ?>
とゆう内容に変えても同様にNullとなります。
ちなみにいずれの実装でもレスポンスコードは200でした。
int status = connection.getResponseCode(); // 200
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。