-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating new PaymentsApi client changes configuration of existing PaymentsApi client #105
Comments
@bryancort thank you for raising this. I have tested our use of this api and I agree with your findings. I have found two workarounds. I am using option 2. Option 1: Set Configuration.Default to null. In this situation, the api creates a a new ApiClient for each PaymentsApi Option 2:
|
I have since found that: apiClient.RestClient = new RestSharp.RestClient("https://apitest.cybersource.com"); does not work. The RestClient is overwritten each time a request is made. The url is not preserved. The url is generated by a lookup using the config dictionary and "runEnvironment" |
Thanks for the followup @wrightsonm - that's useful to know. For option 1, it's the top level Configuration.Default that should be set to null, correct? eg., // do this: // not this Is that right? |
CyberSource.Client.Configuration.Default = null; |
PaymentsApi objects have two config dictionaries: one at the top level (apiInstance.Configuration.MerchantConfigDictionaryObj) and one inside the ApiClient (apiInstance.Configuration.ApiClient.Configuration.MerchantConfigDictionaryObj). The config inside the ApiClient is the config that is used to send requests. This config is overwritten when a new PaymentsApi is created.
Example test demonstrating this issue (remove the .txt for a real .cs file, since the github upload will not accept a .cs file):
PaymentsApiConfigTests.cs.txt
The text was updated successfully, but these errors were encountered: