0

How to use Salesforce Marketing Cloud API to connect with my SQL server database. I need to use C# to do HTTP POST request to acquire an access token, but I have no idea how to do it. I need to run this sample code in C#:

POST https://auth.exacttargetapis.com/v1/requestToken
Content-Type: application/json
{
  "clientId": "gyjzvytv7ukqtfn3x2qdyfsn",
  "clientSecret": "************"
}

I am using SSIS 2008r2, I want to write c# code to make an api call to the exact Target API to connect to SQL server database. Because I want to pull data from SQL server to marketing cloud. I didn't find any article about using SSIS to connect Marketing cloud.....the salesforce marketing cloud rest API or FuelSDK looks like only support .net 4 or higher....

Leo
  • 23
  • 5
  • This question is very broad. Start here: http://stackoverflow.com/questions/9620278/how-do-i-make-calls-to-a-rest-api-using-c – Alec. Oct 21 '15 at 14:18
  • Thanks, I read it before, but most of solutions are using .net 4 or higher, so I am looking for if any chance to use .net 3.5....but it looks difficult... – Leo Oct 21 '15 at 14:29

2 Answers2

0

There is an SDK available for the marketing cloud in C#. Start here: https://code.exacttarget.com/apis-sdks/fuel-sdks/csharp/getting-started-with-the-csharp-sdk.html

AlbertVo
  • 772
  • 4
  • 9
0

This works for me. Move the clientId and client secret to web.config at some point.

    public static async Task<string> getAuth()
    {
        var clientId = "asdfasdfasdfasdfasdfasdf";
        var clientSecret = "asdfasdfasdfasdfasdf";
        using (var client = new HttpClient())
        {
            var values = new Dictionary<string, string>
            {
                {"clientId", clientId},
                {"clientSecret", clientSecret}
            };

            var content = new FormUrlEncodedContent(values);

            var response = await client.PostAsync(string.Format("https://auth.exacttargetapis.com/v1/requestToken"), content);

            var responseString = await response.Content.ReadAsStringAsync();
            return responseString;
        }
    }
user95227
  • 1,853
  • 2
  • 18
  • 36