问题
In am trying to get an access token to call Salesforce Marketing Api through FuelSDK the code is:
NameValueCollection parameters = new NameValueCollection();
parameters.Add("clientId", "myclientidvalugoeshere");
parameters.Add("clientSecret", "myclientsecretvaluegoeshere");
var client = new ETClient(parameters);
ETFolder folder = new ETFolder();
folder.AuthStub = client;
var response = folder.Get();
return response.Message;
But it's returning:
System.Net.WebException : The remote server returned an error: (401) Unauthorized.
I am not really sure if I am doing it the right way.
What I really want to do is to connect to Salesforce Marketing cloud through FuelSDK C#, using Oauth authentication to get access token for the user and call the resources needed.
回答1:
You probably need to add authEndPoint, restEndPoint, as well as useOAuth2Authentication to your NameValueCollection parameters.
Check this out: https://github.com/salesforce-marketingcloud/FuelSDK-CSharp/wiki
回答2:
There's a feature called whitelist. Try to add there Your IP and also double check that You are using the correct API Keys.
From my experience the response You are receiving is becasue the combination of API key strings are not the correct ones.
I would recommend that You try the same keys to do a simple REST API request on the same package. Find more on this here.
来源:https://stackoverflow.com/questions/62916165/calling-marketing-cloud-apis-from-c-sharp-via-fuelsdk