You need to sign in to do that
Don't have an account?
Mel Lisau
How can i use OAuth with Soap API ?
I am tryng to use OAuth to authenticate rather that the traditional username , password.
I can successfuly authenticate and receive back a Instanceurl and token.
But how can i construct a SOAP call using these ?
I tried to follow this link but there is no example.
https://developer.salesforce.com/blogs/developer-relations/2011/03/oauth-and-the-soap-api.html
I have tried to make a request as follows:
strng SOAP_API_SOBJECT_ENDPOINT = "/services/Soap/u/51.0/";
string sobject = "Account"
Account acct = new Account { Name = $"Test123 ", Description = $"Test Description 123[" };
string restendpoint = InstanceUrl + SOAP_API_SOBJECT_ENDPOINT + sobject;
var json = JsonConvert.SerializeObject(acct);
var request = new HttpRequestMessage(HttpMethod.Post, restendpoint);
request.Headers.Add("Authorization", "Bearer " + AuthToken);
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
request.Headers.Add("X-PrettyPrint", "1");
request.Content = new StringContent(json, Encoding.UTF8, "application/json");
var response = client.SendAsync(request).Result;
return response.Content.ReadAsStringAsync().Result;
The result is Internal Server Error.
Is this the correct way to use OAuth with Soap API ?
I can successfuly authenticate and receive back a Instanceurl and token.
But how can i construct a SOAP call using these ?
I tried to follow this link but there is no example.
https://developer.salesforce.com/blogs/developer-relations/2011/03/oauth-and-the-soap-api.html
I have tried to make a request as follows:
strng SOAP_API_SOBJECT_ENDPOINT = "/services/Soap/u/51.0/";
string sobject = "Account"
Account acct = new Account { Name = $"Test123 ", Description = $"Test Description 123[" };
string restendpoint = InstanceUrl + SOAP_API_SOBJECT_ENDPOINT + sobject;
var json = JsonConvert.SerializeObject(acct);
var request = new HttpRequestMessage(HttpMethod.Post, restendpoint);
request.Headers.Add("Authorization", "Bearer " + AuthToken);
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
request.Headers.Add("X-PrettyPrint", "1");
request.Content = new StringContent(json, Encoding.UTF8, "application/json");
var response = client.SendAsync(request).Result;
return response.Content.ReadAsStringAsync().Result;
The result is Internal Server Error.
Is this the correct way to use OAuth with Soap API ?
What is the Oauth flow you are using?
Recommend reviewing
https://salesforce.stackexchange.com/questions/194440/soap-method-of-authentication
https://salesforce.stackexchange.com/questions/255877/soap-api-call-oauth-2-0-error
https://salesforce.stackexchange.com/questions/1210/using-the-soap-api-with-oauth
If this information helps, please mark the answer as best. Thank you