Calling Marketing Cloud APIs from C# via FuelSDK

a 夏天 提交于 2021-02-11 15:34:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!