title: Http post 405 Method Not Allowed
body: <p>Apologize if this is a newbie question or for using inaccurate terminology. coz I am a newbie.</p>
  
  <p>I built a simple python api to read and write into a database (csv file) 
  my front end is Angular 5.
  I managed to get the data in full from the file on the server, but I cannot post to it. Here is the issue (it seems!)</p>
  
  <p>The method I am using is post and the data is an array of JSON.</p>
  
  <p>This is the code of interest:
  component.ts side:</p>
  
  <pre><code>this._svc.postAPI(this.csvData)
      .subscribe(
        res =&gt; console.log(res),
      error =&gt; alert('Error!'),
    ()=&gt; 'Data Submitted to database') 
    }
  </code></pre>
  
  <p>services.ts side:</p>
  
  <pre><code>postAPI(data): Observable&lt;any&gt;{
      return this.http.post(this.urlAPI, data);
    }
  </code></pre>
  
  <p>Error I am getting is 405 Method Not Allowed and console's Network shows:</p>
  
  <p><strong>General</strong></p>
  
  <pre><code>Request URL: http://192.168.0.2:5050/api
  Request Method: OPTIONS
  Status Code: 405 Method Not Allowed
  Remote Address: 192.168.0.2:5050
  Referrer Policy: no-referrer-when-downgrade
  </code></pre>
  
  <p><strong>Response Headers</strong></p>
  
  <pre><code>Allow: POST
  Content-Length: 23
  Content-Type: text/plain; charset=utf-8
  Date: Thu, 12 Jul 2018 03:20:39 GMT
  Server: Python/3.5 aiohttp/2.3.10
  </code></pre>
  
  <p><strong>Request Headers</strong></p>
  
  <pre><code>Accept: */*
  Accept-Encoding: gzip, deflate
  Accept-Language: en-US,en;q=0.9
  Access-Control-Request-Headers: content-type
  Access-Control-Request-Method: POST
  Connection: keep-alive
  Host: 192.168.0.2:5050
  Origin: http://evil.com/
  User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 
  (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
  </code></pre>
  
  <p>Everything works fine using postman, the URL seems to be correct but the issue seems to be with the data itself.</p>
  
  <p>I tried these:</p>
  
  <p>This did NOT work:</p>
  
  <pre><code>postAPI(data): Observable&lt;any&gt;{
  return this.http.post(this.urlAPI, '{}');
  }
  </code></pre>
  
  <p>but this DID work:</p>
  
  <pre><code>postAPI(data): Observable&lt;any&gt;{
  return this.http.post(this.urlAPI, '[{}]');
  }
  </code></pre>
  
  <p>and this DID work:</p>
  
  <pre><code>postAPI(data): Observable&lt;any&gt;{
  return this.http.post(this.urlAPI, '
  [
      {
          "info": "A",
          "dev": "T",
          "but": "C",
          "msg": "X"
      }
  ]
  ');
      }
  </code></pre>
  
  <p>I believe the data that I am trying to post is also in this exact format, a JSON array.</p>
  
  <p>Any assistance is greatly appreciated.</p>