'How to get Mailchimp Datacenter name

We have a lambda functions in C# to create campaigns in Mailchimp, the problem I am facing is there could be different Mailchimp accounts for different customers which means the Base API URL could be https://us20.api.mailchimp.com or https://us6.api.mailchimp.com.

Is there a way I can retrieve Mailchimp datacenter names using the access token which I have and thereby set the right value for Base API URL within Lambda functions?

I have tried what is mentioned here https://mailchimp.com/developer/marketing/guides/access-user-data-oauth-2/ but only see an error

'{"error":"invalid_token","error_description":"Unable to load login and user"}**



Solution 1:[1]

You can get mailchimp metadata url from this endpoint

https://login.mailchimp.com/oauth2/metadata

make an HTTP GET request to the above URL with a valid access token sent as request header in this format

Request Header

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 CSharped