Skip to content

Instantly share code, notes, and snippets.

@devdiva
Created June 22, 2011 20:37
Show Gist options
  • Save devdiva/1041105 to your computer and use it in GitHub Desktop.
Save devdiva/1041105 to your computer and use it in GitHub Desktop.
ApiInfusionsoft error "undefined method `api_perform' for nil:NilClass"
# config/initializers/api_infusionsoft.rb
# actual file contains reall app and key values.
ApiInfusionsoft.set_account_apiconn("MYAPP.infusionsoft.com", "MYKEY")
class UsersController < ApplicationController
include ApiInfusionsoft
def index
@users = User.all
infuser = api_data_query(:Contact,1,0,{:Id=>3674}, ["Id", "FirstName", "LastName"])
print "\n infuser #{infuser.inspect}"
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @users }
end
end
# other methods rm'd for this example.
end
@devdiva
Copy link
Author

devdiva commented Jun 22, 2011

Basically, the error is called from the following type of method cal in the ApiInfusionsoft plugin. It doesn't matter what method is called, because Thread.current[:api_conn] is returning nil.

Thread.current[:api_conn].api_perform('DataService', 'load', table, id, selected_fields)

Here are the relevant lines from the error message:

NoMethodError in UsersController#index
undefined method `api_perform' for nil:NilClass
vendor/plugins/api_infusionsoft/lib/api_infusionsoft.rb:247:in `api_data_query'

@nateleavitt
Copy link

Hello.. I'll check it out, and respond later this evening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment