Mangopay / mangopay2-ruby-sdk

Ruby Gem for MANGOPAY
https://rubygems.org/gems/mangopay
MIT License
42 stars 38 forks source link

Can't create a user: The requested resource does not support http method 'POST'. (MangoPay::ResponseError) #153

Closed noff closed 4 years ago

noff commented 4 years ago

Hello.

I'm trying to create a user using Ruby SDK.

Here is an example of code:

require 'mangopay'

# configuration
MangoPay.configure do |c|
  c.preproduction = true
  c.client_id = '****'
  c.client_apiKey = '****'
  c.log_file = File.join('.', 'mangopay.log')
  c.http_timeout = 10000
end

## Create project owner

data = {
    FirstName: 'Johny',
    LastName: 'Mnemomic',
    Birthday: 358336200,
    Nationality: 'FR',
    CountryOfResidence: 'FR',
    Email: 'someemail@gmail.com'
}
po = MangoPay::User.create data, 1

It raises the error:

/Users/me/.rvm/gems/ruby-2.3.3/gems/mangopay-3.0.33/lib/mangopay.rb:148:in "request": The requested resource does not support http method 'POST'. (MangoPay::ResponseError)
    from /Users/me/.rvm/gems/ruby-2.3.3/gems/mangopay-3.0.33/lib/mangopay/http_calls.rb:13:in "create"
    from /Users/me/Developer/mangopay/mangopay.rb:23:in "<main>"

Log in mangopay.log file:

E [2019-11-25T14:19:17+03:00] POST "https://api.sandbox.mangopay.com/v2.01/****/users/1" {"FirstName":"Johny","LastName":"Mnemomic","Birthday": 358336200,"Nationality":"FR","CountryOfResidence":"FR","Email":"someemail@gmail.com"}
  [297.7ms] 405 {"Message":"The requested resource does not support http method 'POST'."}

I'm using sandbox account.

Mangopay gem version: mangopay (3.0.33) Ruby version 2.3.3

SoloJr commented 4 years ago

@noff hello and sorry for the late response. The error does not come from the sdk or ruby. You could read the documentation about Users here: https://docs.mangopay.com/endpoints/v2.01/users#e253_the-user-object

This would help. It is normal that you get that message as you are requesting the natural user with id 1 with your request. Basically you are doing a GET, not a POST.

A second thing, you can create either a Legal User, or a Natural User. The call you should make is po = MangoPay::NaturalUser.create data