Skip to content
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

ApiClient creates new instance of RestClient #39

Open
sipsorcery opened this issue May 28, 2022 · 2 comments · May be fixed by #40
Open

ApiClient creates new instance of RestClient #39

sipsorcery opened this issue May 28, 2022 · 2 comments · May be fixed by #40

Comments

@sipsorcery
Copy link

sipsorcery commented May 28, 2022

While attempting, and failing, to set the timeout for HTTP calls to the CyberSource gateway via the Configuration.Timeout I tracked it down to a second instance of the RestClient being created.

I'm not really sure what the code is meant to be doing at that point. It seems like ApiClient creates a RestClient instance in its contructor with the intention of using it for the API call. Configuration values are applied to that instance. But then a brand new instance is created in CallAuthenticationHeaders and it does not have the Configuration values applied.

I can fix my problem by changing:

RestClient = new RestClient("https://" + merchantConfig.HostName);

to

RestClient.BaseUrl = new Uri("https://" + merchantConfig.HostName);

It does seem to be a somewhat confusing and error prone approach. It would seem better to stick to setting the hostname in the ApiClient constructor rather than burying it down in an entry in the Configuration.MerchantConfigDictionaryObj dictionary.

sipsorcery added a commit to nofrixion/cybersource-rest-client-dotnetstandard that referenced this issue May 28, 2022
@sebastian-sawicki
Copy link

This issue is related with issue #26 which my team reported. We also pointed to CallAuthenticationHeaders where new instance of RestClient is recreated.

I raise also separate #46 "Update RestSharp to v107 and follow recommended usage".

@DatMarsupial
Copy link

DatMarsupial commented May 9, 2023

My team and I would also love to see this resolved! We're trying to create a custom delegating handler in our pipeline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants