0
votes

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.

2

2 Answers

0
votes

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

0
votes

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.