fix "must use account-specific domains" error with newer API versions#439
fix "must use account-specific domains" error with newer API versions#439q3aiml wants to merge 1 commit intoNetSweet:masterfrom
Conversation
Newer API versions require using the account-specific domains such as
`<account-id>.suitetalk.api.netsuite.com`. The WSDLs for these versions,
however, specify the generic `webservices.netsuite.com` domain. When
`wsdl_domain` is provided use this to override the endpoint so the
account-specific domain can be used and users can successfully use
2019_1.
I create the client first without the `endpoint` override to allow
reading the default endpoint from the client. Then `wsdl_domain` is
substituted into the default which avoids hardcoding the path in the gem
(`/services/NetsuitePort_#{api_version}`).
|
Note that you can also patch something like this into a codebase using the current version of the gem with something like this: module NetSuite
module Configuration
extend self
alias :old_connection :connection
def connection(params={}, credentials={})
client = old_connection(params, credentials)
client.wsdl.endpoint = client.wsdl.endpoint.to_s.sub('//webservices.netsuite.com/', "//#{wsdl_domain}/")
client
end
end
end |
|
Helped me out -- thank for this! |
|
Thank you! This also helped me. |
|
Hey All! Still haven't had time to dig into this contribution and get it mixed it. Will hopefully get to this sooner rather than later. |
module NetSuite
module Configuration
extend self
alias :old_connection :connection
def connection(params={}, credentials={})
client = old_connection(params, credentials)
client.wsdl.endpoint = client.wsdl.endpoint.to_s.sub('//webservices.netsuite.com/', "//#{wsdl_domain}/")
client
end
end
end
NetSuite.configure do
reset!
account ENV['NETSUITE_ACCOUNT_ID']
consumer_key ENV['NETSUITE_CLIENT_ID']
consumer_secret ENV['NETSUITE_CLIENT_SECRET']
token_id ENV['NETSUITE_TOKEN_ID']
token_secret ENV['NETSUITE_TOKEN_SECRET']
api_version ::NETSUITE_API_VERSION
wsdl_domain ::NETSUITE_WSDL_DOMAIN
endIn my
|
|
@ohaddahan I haven't been using netsuite for some time so I am afraid I won't be much help. I'll close to this for clarity. If anyone who still has the ability to test this change wants to open a new PR please feel free to use my patch (as hacky as it is!). |
|
@ohaddahan (and others) (copying my comment verbatim from #445 (comment)) To get going with Below is for a totally made up NetSuite.configure do
reset!
api_version '2020_2'
account "0000000_SB1"
consumer_key "xxxxx"
consumer_secret "xxxxx"
token_id "xxxxx"
token_secret "xxxxx"
# pull the following from `NetSuite::Utilities.data_center_url('0000000_SB1')` every time? once year? never? always?
wsdl_domain "0000000-sb1.suitetalk.api.netsuite.com"
end
module NetSuite
module Configuration
extend self
alias :old_connection :connection
def connection(params={}, credentials={})
client = old_connection(params, credentials)
wsdl = client.wsdl_netsuite_endpoint_hack
# from "https://webservices.netsuite.com/services/NetSuitePort_2020_2" to "https://#{wsdl_domain}/services/NetSuitePort_2020_2"
wsdl.endpoint = wsdl.endpoint.to_s.gsub(%r[//[^/]*/], "//#{wsdl_domain}/") #
client
end
end
end
# above hack fails with undefined method `wsdl' for #<Savon::Client:0x00007fa07cb5c2e0> otherwise
module Savon
class Client
def wsdl_netsuite_endpoint_hack
return self.wsdl if self.respond_to?(:wsdl)
@wsdl
end
end
end |
|
For any googlers, this was fixed with #473 |
Newer API versions require using the account-specific domains such as
<account-id>.suitetalk.api.netsuite.com. The WSDLs for these versions,however, specify the generic
webservices.netsuite.comdomain. Whenwsdl_domainis provided use this to override the endpoint so theaccount-specific domain can be used and users can successfully use
2019_1.
I create the client first without the
endpointoverride to allowreading the default endpoint from the client. Then
wsdl_domainissubstituted into the default which avoids hardcoding the path in the gem
(
/services/NetsuitePort_#{api_version}).If this seems too messy I can instead (in addition?) open a PR that adds
a
wsdl_overrideoption.Thanks for looking.
Fixes #430
Fixes #434