I get a Net::HTTPUnauthorized 401 Unauthorized updating bank_transaction_explanation


#1

Why am I getting this error when I update the bank transaction explanation
Net::HTTPUnauthorized 401 Unauthorized

These are the parameters
params = {“bank_transaction_explanation”=>{“bank_account”=>“https://api.freeagent.com/v2/bank_accounts/600152”, “category”=>“https://api.freeagent.com/v2/categories/004”, “dated_on”=>“2019-03-18”, “description”=>“Test transaction explanation from zee2”, “transaction_description”=>"///RM888.88", “gross_value”=>“888.88”, “foreign_currency_value”=>“0.0”, “transfer_value”=>"-888.88", “type”=>“Sales”, “is_money_in”=>true, “is_money_out”=>false, “is_money_paid_to_user”=>false, “url”=>“https://api.freeagent.com/v2/bank_transaction_explanations/160090212”, “bank_transaction”=>“https://api.freeagent.com/v2/bank_transactions/177795990”, “detail”=>"Awanmulan booking. Inc RM8.98 Sales Tax ", “is_locked”=>false, “marked_for_review”=>false, “has_pending_operation”=>false}}

uri = URI.parse(“https://api.freeagent.com/v2/bank_transaction_explanations/160090212”)
uri.query = URI.encode_www_form( params ) if params.present?
request = Net::HTTP::Put.new(uri)
request.content_type = “application/json”
request[“Authorization”] = “Bearer #{token}”
request[“Accept”] = “application/json”

response = Net::HTTP.start(uri.hostname, uri.port, {use_ssl: uri.scheme == “https”}).request(request)