title: OkHTTP Post Error 405
body: <p>I'm trying to send data from an Android device to a web server using Flask. 
  I'm just testing by returning some strings. 
  <br>If I do a post request on POSTMAN to <code>IP_Address/playlists</code> with <code>{"spotify_token":"test token"}</code> I'll get the proper response. <code>{"result":"received token"}</code>
  <br>But if I try to send a similar HTTP Post request on Android with OkHTTP I get error 405. <code>192.168.0.105 - - [19/Jul/2018 17:23:37] "POST //playlists HTTP/1.1" 405 -</code>
  <p>Response from server:
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Allow: HEAD, GET, OPTIONS
      Content-Length: 178
      Server: Werkzeug/0.14.1 Python/3.7.0
      Date: Fri, 20 Jul 2018 01:57:56 GMT
      &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"&gt;
      &lt;title&gt;405 Method Not Allowed&lt;/title&gt;
      &lt;h1&gt;Method Not Allowed&lt;/h1&gt;
      &lt;p&gt;The method is not allowed for the requested URL.&lt;/p&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><p>I checked my code with other answers and as far as I can tell it looks correct.. Also, I'm able to do a GET request in my home page fine. 
  <p>Android Code</p>
  
  
  
  <pre><code>private static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
  
      public void onClick(View view){
          client = new OkHttpClient();
          JSONObject jsonObject = new JSONObject();
          try {
              jsonObject.put("UserId", "test token");
          } catch (JSONException e) {
               e.printStackTrace();
          }
          RequestBody requestBody = RequestBody.create(JSON, jsonObject.toString());
  
          Request request = new Request.Builder()
                  .url(IP_ADDRESS + "/playlists")
                  .post(requestBody)
                  .build();
  
          client.newCall(request).enqueue(new Callback() {
              @Override
              public void onFailure(Call call, IOException e) {
                  Log.e("ExportButton", e.toString());
              }
              @Override
              public void onResponse(Call call, Response response) throws IOException {
                  Log.e("ExportButton", response.body().string());
                  if(response.isSuccessful()){
                      final String myResponse = response.body().string();
                      MainActivity.this.runOnUiThread(new Runnable() {
                          @Override
                          public void run() {
                              messageWindow.setText(myResponse);
                          }
                      });
                  }
              }
          });
  </code></pre>
  
  <p><p>Flask code</p>
  
  
  
  <pre><code>    @app.route('/playlists', methods =["POST"])
      def get_playlists():
          data = request.get_json()
          spotify_token = data['spotify_token']
          print(spotify_token)
          return jsonify({'result': 'received token'})
  </code></pre>