1

I have written a tool to get the OAuth JWT Token Bearer from salesforce but do not know what to do next to get my data.

The examples in salesforce look easy but they are using curl and I do not know hwo to do this in c# e.g.

curl https://instance_name.salesforce.com/services/data/v46.0/ -H "Authorization: Bearer 00D50000000IehZ!AQcAQH0dMHZfz972Szmpkb58urFRkgeBGsxL_QJWwYMfAbUeeG7c1E6 LYUfiDUkWe6H34r1AAwOR8B8fLEz6n04NPGRrq0FM"

Anyone who can help me here?

1

1 Answer 1

1

Unofficial .NET toolkit is one option:

The Force.com Toolkit for .NET provides an easy way for .NET developers to interact with the Lighting Platform APIs using native libraries

Without the toolkit, here's a simple C# method that runs an arbitrary SOQL query

public string Query(string soqlQuery, String token, String instance) {
            using (var client = new HttpClient())
            {
                string url = "https://" + instance + ".salesforce.com/services/data/v46.0/query/?q=" + soqlQuery;
                var request = new HttpRequestMessage(HttpMethod.Get, url);
                request.Headers.Add("Authorization", "Bearer " + token);
                request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                request.Headers.Add("X-PrettyPrint", "1");
                var response = client.SendAsync(request).Result;
                return response.Content.ReadAsStringAsync().Result;
            }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .