lob/lob-ruby

Requests to bulk US verifications are invalid.

Closed this issue ยท 6 comments

I'm trying to make requests to the Bulk Verify endpoint https://docs.lob.com/#operation/bulk_us_verifications using this gem, but the requests end up wrong.

lob =
  Lob::Client.new(api_key: API_KEY)

addresses =
  [
    {
      'primary_line' => '323 Greenwich St Apt 5',
      'state' => 'NY',
      'city' => 'New York',
      'zip_code' => '10013'
    },
    {
     'primary_line' => '50 Riverside Blvd Apt 12B',
      'state' => 'NY',
      'city' => 'New York',
      'zip_code' => '10069'
    },
    {
      'primary_line' => '22 Christopher St',
      'state' => 'NY',
      'city' => 'New York',
      'zip_code' => '10014'
    },
    {
      'primary_line' => '45 West 67th Street Apt 33B',
      'state' => 'NY',
      'city' => 'New York',
      'zip_code' => '10023'
    }
  ]

response =
  lob.bulk_us_verifications.verify(addresses: addresses)

puts response # {"addresses"=>[{"error"=>{"message"=>"city must be a string", "status_code"=>422}}], "errors"=>true}

This is the request body that I see in the dashboard:

image

I'm guessing rest-client is at fault but couldn't debug it yet. If I'm doing something wrong let me know.

Thanks for using Lob! You weren't doing anything wrong. There is an error in how we are sending the payload to the RestClient. The fix is in this PR.

FYI I'm still seeing the same error with 5.4.4. If it helps the rest-client version is 2.1.0.

I'm going to investigate this further. I thought the payload issue was fix.

So, it looks like you have to convert the array of addresses to JSON before passing it to the verify method.

response =
  lob.bulk_us_verifications.verify(addresses: addresses.to_json)

puts response

Screen Shot 2021-12-29 at 5 47 50 PM

This isn't exactly user-friendly, so we'll look into making a change to fix this so that you can just pass in the Ruby hashes instead of doing that conversion after the holidays. In the meantime, this solution won't block you from using the library.

Happy holidays!

Thanks ๐Ÿ™ I tried this before and wasn't successful, but probably the change in 5.4.4 allows for this now, will try it out.

@gdotdesign Yes, please try 5.4.5 or 5.4.6. The latter will allow you to pass in the array of hashes like you originally wanted.