0

I'm new to Ruby, and currently trying to create a login step however somehow even after I fill in the value, it comes back with

      Request: {"headers":{},"timeout":60,"body":"{\n\t\"email\": \"johnsnow@gmail.com\",\n\"password\": \"AnotherJ0hnSnow\"\n}"}
      Response code: 400
      Response time: 78 ms
      Response body: {"message":{"email":"cannot be blank","password":"cannot be blank"}}
{"message":{"email":"cannot be blank","password":"cannot be blank"}}

Even when I already fill it with

    When client sends a POST request to "XXXX" with body: 
      """
      {
        "email": "johnsnow",
        "password": "AnotherJ0hnSnow"
      }
      """

Did I miss something?

Trying to log in by using the value that I input in the body

I already tried just using the token however somehow it still got 400 with an empty field

@access_token = ENV['API_TOKEN']
puts "access_token : #{@access_token}"

@headers = {
  'Content-Type' => 'application/json',
  'Accept' => 'application/json',
  'Authorization' => "Bearer #{@access_token}"
}

I also tried searching but somehow I didn't get what I'm looking for from the thread like: Password can't be blank or "Password can't be blank" Rails Rails 4.2.4 by giving put, it shows up but still somehow it rejects in this step

Bek
  • 2,206
  • 20
  • 35
Miles
  • 1
  • 1
  • 2
    Check you strong_params in your controller. Generally speaking, when presenting a problem you also need to show us your current code, otherwise this is just guessing. And please sanitize your logs - password should never appear in the logs unredacted, it's a serious security risk! – BroiSatse Oct 30 '22 at 11:46
  • The fact that the request is coming in as a JSON string, and not JSON parameters, is likely a sign you're posting to the service incorrectly. Those parameters are missing. All you have is a `body` full of junk as far as Rails is concerned. How do you post this? What stack are you using? Maybe you need to enable JSON decoding. – tadman Oct 30 '22 at 16:15

0 Answers0