0

私は最後の日をRailsアプリでこれを機能させるために費やしましたが、継続的に応答を受け取ります:

{"code"=>"E-C-343", "message"=>"Unrecognized JSON Request."}

BancBoxのドキュメントはかなり軽いので、これを解決する方法について少し行き詰まっています。

誰かがRESTを利用してBancBoxでcreateClientへの成功したAPI呼び出しの例を持っていますか?

HTTPartyを利用した私のPostAPI呼び出し:

include HTTParty
format :json

def save_with_bancbox(params = {})

  post_params = { :authentication =>  { :apiKey => BANCBOX_KEY,
                                        :secret => BANCBOX_SECRET
                                        },
                  :subscriberId => BANCBOX_ID,
                  :firstName => params[:first_name],
                  :lastName => params[:last_name],
                  :ssn => params[:ssn],
                  :dob => params[:dob],
                  :address => { :line1 => params[:address_line_1],
                                :line2 => params[:address_line_2],
                                :city => params[:city],
                                :state => params[:state],
                                :zipcode => params[:zipcode]
                                },
                  :homePhone => params[:dob],
                  :email => params[:email]
                  }

  response = HTTParty.post( BANCBOX_REST_URL, 
                            :body => post_params)

    logger.debug "Response -- #{response}"

  save!

end
4

2 に答える 2

2

apikey、secret、subscriberidを変更した後、以下のコードを試してください


require "net/https"

require 'rubygems'

require 'json'

require 'httparty'


###########################bancbox.rb in config/initializers#################

BANCBOX_API_KEY = "__KEY__"

BANCBOX_API_SECRET = "__SECRET__"

BANCBOX_SUBSCRIBER_ID = "__SUB_ID__"

BANCBOX_API_URL = "https://sandbox-api.bancbox.com/BBXPortRest"

module Bancbox

        class API

                include HTTParty 
                debug_output $stdout
                base_uri "#{BANCBOX_API_URL}"

                def initialize(u=BANCBOX_API_KEY,p=BANCBOX_API_SECRET)
                        auth = {:apiKey => u, :secret => p}
                        @options = {:body => {:authentication =>auth,:subscriberId=>BANCBOX_SUBSCRIBER_ID}, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' }}
                end

                #USERS
                def create_client(options={})  
                        options = options.merge(@options[:body])
                        @options.merge!({:body => options.to_json})
                        response = self.class.post("/createClient",@options)
                        #required_fields- subscriberId,firstName,lastName,ssn,dob,address,homePhone,email
                end

                def get_schedules(options={})
                        @options.merge!({:query => {:subscriberId => BANCBOX_SUBSCRIBER_ID}})
                        @options.merge!({:query => options})
                        self.class.post("/getSchedules",@options)
                end
        end
end

b = Bancbox::API .new


b.create_client({:firstName=> "Bipen",:lastName=> "Sasi",:ssn=>"334-444-4444",:dob=> Date.parse("January 1st 1988"), :address=>{:line1=> "4408 walnut st", :line2=>"apt 3r",:city=> "philly",:state=>"pa",:zipcode=>"19110"}, :homePhone=> "2672551161",:email=>"bipen@lokalty.com"})
于 2012-10-10T21:20:59.117 に答える
0

リクエストをPOSTする必要があると思います

https://sandbox-api.bancbox.com/BBXPortRest/createClient

それ以外の

https://sandbox-api.bancbox.com/BBXPortRest/

また、コンテンツタイプをapplication/jsonとして設定してください

通常、リクエストはhttps://sandbox-api.bancbox.com/BBXPortRest/ <method >に投稿します。

于 2012-08-14T02:26:33.110 に答える