title: How to log in to this website using requests library?
body: <p>I am writing a very simple web scraper, but I need to log-in to a particular website which requires to fill in a form. </p>
  
  <p>The link to the website I am talking about: "<a href="https://odrabiamy.pl" rel="nofollow noreferrer">https://odrabiamy.pl</a>"</p>
  
  <p>The form sends a POST request to this endpoint: "<a href="https://odrabiamy.pl/api/v1.3/sessions.json" rel="nofollow noreferrer">https://odrabiamy.pl/api/v1.3/sessions.json</a>" with this payload: </p>
  
  <pre><code>{"user": {"login": "my email address","password": "my password"}}
  </code></pre>
  
  <p>I figured it out using Chrome Dev Tools. </p>
  
  <p>The problem is with my code. I try to send a POST request with this payload, but the issue is that it returns an error and I don't know how to figure it out. </p>
  
  <p>It returns this error:</p>
  
  <pre><code>{
      "message": "Nieznana metoda autentykacji"
  }
  </code></pre>
  
  <p>It translates to "unknown authentication method". </p>
  
  <p>I also checked a status code my request returns and it is 400.</p>
  
  <p><img src="https://i.imgur.com/qdPxND9.png" alt="Program"></p>
  
  <p>My code: </p>
  
  <pre class="lang-py prettyprint-override"><code>import requests
  import json
  from bs4 import BeautifulSoup
  
  
  class Podrabiamy:
  
      def __init__(self):
          self.login_url = "https://odrabiamy.pl/api/v1.3/sessions.json"
          self.data = {"user": {"login": "xxxxxxxx", "password": "xxxxxxx"}}
          self.headers = {'content-type': 'application/json'}
  
      def login(self):
          with requests.Session() as session:
              response = session.post(self.login_url, data=json.dumps(self.data), headers=self.headers)
              print(response.content)
              print(response.status_code)
  
  
  if __name__ == "__main__":
      podrabiamy = Podrabiamy()
      podrabiamy.login()
  
  </code></pre>