brandonseydel/MailChimp.Net

Changing ApiKey and DataCenter does not change request URLs

Closed this issue · 8 comments

I have a .NET Core application that iterates over multiple API Keys that exist in separate data centers. When switching between API keys the underlying data center component of request URLs does not change. The code does not re-use the same MailChimpManager, an entirely new copy is instantiated for each API Key used.

Having looked at the code for BaseLogic.cs my guess is has something to do with the use of the static IHttpClientFactory.

Whilst I don't pretend to fully follow the code, on line 40 the call:

client.BaseAddress = new Uri(GetBaseAddress());               

Would appear to run when _httpClientFactory is instantiated and therefore the initial values of the base URL would persist for the lifetime of the application.

I have the same problem. Reverted to preview version 4.2.1 because of this

I have the same problem. We are a SaaS provider and have received thousands of errors since upgrading to v5.0.0. Reverted to 4.2.1 because of this - and it fixed the issue. Thanks @sampayne - for pointing this out.

{
"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/",
"title":"Forbidden",
"status":403,
"detail":"The API key provided is linked to datacenter 'us3'",
"instance":"f2d6... ...40f"
}

Just to pile on - we've just experienced this as well, caught it early but still extremely surprising that this pretty fundamental problem has been introduced.

I say this with kindness and I understand that being an OSS maintainer is a thankless business (having done it myself), but is this project really being actively maintained now, and @brandonseydel do you have the bandwidth to continue doing it? I think V5.0.0 should be pulled and an announcement made to put this on ice and make v4.x.x bugfix only.

Let me check it out. Ill diff it and see what happened...

I pushed the fix. I will release a new package.

Let me know if this worked for you 5.1.0 and I will close out. I have to get new api keys from mail chimp for testing.

Any comments?

I upgraded today and so far so good ;)