• Fenil Suthar 007
  • NEWBIE
  • 20 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 2
    Replies
Rest API - SOQL Query :
When I Query i am able to get all user's record instead of mine only. Is there any way to filter for get records of current user only.
Example for creating Opportunity :
curl https://na1.salesforce.com/services/data/v20.0/sobjects/Opportunity/0AASSFGSEID -H "Authorization: Bearer token" -H "Content-Type: application/json" -d @newrecord.json -X PATCH
Example request body newrecord.json file :
{ "Name":"FFNEw","CloseDate":"2015/02/04","StageName":"Prospecting","Probability":10 }
My ASP.net code :
 
using (WebClient client = new WebClient())
{
client.Headers.Add("Authorization", "Bearer " + token.access_token); client.Headers.Add("Content-Type", "application/json");
var request = (HttpWebRequest)(HttpWebRequest.Create(token.instance_url + "/services/data/v20.0/sobjects/Opportunity/0AASSFGSEID"));
request.Method = "PATCH";
using (var requestWriter = new StreamWriter(request.GetRequestStream()))
{
  requestWriter.Write(json);
  requestWriter.Flush();
  requestWriter.Close();
}
var response = request.GetResponse();
}
Getting Error 400 Bad Request in "request.GetResponse()".

 
How to get Fields/Custom Fields list of an Object(Opportunity etc..)  Using Tooling API in .net.
I want SalesForce All Fields List including Custom Fields Using API call. Is It possible using API?
I want to create Multiple Opportunity Using .net Code & Salesforce Connected APP Callback URL. I have tried using Rest API but Rest API Only Allow insert one record At Time.
Example for creating an Opportunity :
curl https://na1.salesforce.com/services/data/v20.0/sobjects/Opportunity/ -H "Authorization: Bearer token" -H "Content-Type: application/json" -d @newrecord.json -X PATCH
Example request body newrecord.json file :
{ "Name":"FFNEw","CloseDate":"2015-05-02","StageName":"Prospecting","Probability":10 }
My ASP.net code :
using (WebClient client = new WebClient())
{
client.Headers.Add("Authorization", "Bearer " + token.access_token); client.Headers.Add("Content-Type", "application/json");
var request = (HttpWebRequest)(HttpWebRequest.Create(token.instance_url + "/services/data/v20.0/sobjects/Opportunity/"));
request.Method = "POST";
using (var requestWriter = new StreamWriter(request.GetRequestStream()))
{
  requestWriter.Write(json);
  requestWriter.Flush();
  requestWriter.Close();
}
var response = request.GetResponse();
}
I am able to create a single opportunity using above code. But when i try to create multiple record using below "newrecord.json" file getting error.

Example request body for multiple record newrecord.json file :
[{"Name":"Opp1","CloseDate":"2015-05-02","StageName":"Stage1","Probability":"10","Amount":"1500"},{"Name":"Opp2","CloseDate":"2015-02-03","StageName":"Stage2","Probability":"5","Amount":"2000"}]

Error in .net Code : 400 bad request
Error in Workbench : errorCode: METHOD_NOT_ALLOWED
message: HTTP Method 'POST' not allowed. Allowed are HEAD,GET





 
Example for creating Opportunity :
curl https://na1.salesforce.com/services/data/v20.0/sobjects/Opportunity/ -H "Authorization: Bearer token" -H "Content-Type: application/json" -d @newrecord.json -X PATCH
Example request body newrecord.json file :
{ "Name":"FFNEw","CloseDate":"3/2/2015","StageName":"Prospecting","Probability":10 }
My ASP.net code :
using (WebClient client = new WebClient())
{
client.Headers.Add("Authorization", "Bearer " + token.access_token); client.Headers.Add("Content-Type", "application/json");
var request = (HttpWebRequest)(HttpWebRequest.Create(token.instance_url + "/services/data/v20.0/sobjects/Opportunity/"));
request.Method = "POST";
using (var requestWriter = new StreamWriter(request.GetRequestStream()))
{
  requestWriter.Write(json);
  requestWriter.Flush();
  requestWriter.Close();
}
var response = request.GetResponse();
}
Getting Error 400 Bad Request in "request.GetResponse()".
I am able to create Account using same code. I don't Know what wrongs with Opportunity.
Example for creating Accountcurl
https://na1.salesforce.com/services/data/v20.0/sobjects/Account/customExtIdField__c/11999 -H "Authorization: Bearer token" -H "Content-Type: application/json" -d @newrecord.json -X PATCH
Example request body newrecord.json file
{ "Name" : "Express Logistics and Transport" }
My ASP.net code :
using (WebClient client = new WebClient()) 
{ 
client.Headers.Add("Authorization", "Bearer " + token.access_token); client.Headers.Add("Content-Type", "application/json"); NameValueCollection reqparm = new NameValueCollection(); reqparm.Add("Name", "This Is Test Data"); byte[] responsebytes = client.UploadValues(token.instance_url + "/services/data/v20.0/sobjects/Account/customExtIdField__c/11999", "PATCH", reqparm); string responsebody = Encoding.UTF8.GetString(responsebytes); 
}
Above code is not working. Getting Error (405) Method Not Allowed. I don't know how to use Patch Method.
I have used bellow URL to get opportunity list using SOQL Query in .net Web application :

token.instance_url +"/services/data/v33.0/query?q=SELECT+Id,Name+FROM+Opportunity"

In SQL Query we can write Insert,Update,Delete,Select Statement. But, SOQL Only Support Select Statement.

Can i create opportunity using URL like Above.?

Or Any other way to create opportunity using .net web application.
I have used bellow URL to get opportunity list using SOQL Query in .net Web application :

token.instance_url +"/services/data/v33.0/query?q=SELECT+Id,Name+FROM+Opportunity"

In SQL Query we can write Insert,Update,Delete,Select Statement. But, SOQL Only Support Select Statement.

Can i create opportunity using URL like Above.?

Or Any other way to create opportunity using .net web application.
Rest API - SOQL Query :
When I Query i am able to get all user's record instead of mine only. Is there any way to filter for get records of current user only.
Example for creating Opportunity :
curl https://na1.salesforce.com/services/data/v20.0/sobjects/Opportunity/ -H "Authorization: Bearer token" -H "Content-Type: application/json" -d @newrecord.json -X PATCH
Example request body newrecord.json file :
{ "Name":"FFNEw","CloseDate":"3/2/2015","StageName":"Prospecting","Probability":10 }
My ASP.net code :
using (WebClient client = new WebClient())
{
client.Headers.Add("Authorization", "Bearer " + token.access_token); client.Headers.Add("Content-Type", "application/json");
var request = (HttpWebRequest)(HttpWebRequest.Create(token.instance_url + "/services/data/v20.0/sobjects/Opportunity/"));
request.Method = "POST";
using (var requestWriter = new StreamWriter(request.GetRequestStream()))
{
  requestWriter.Write(json);
  requestWriter.Flush();
  requestWriter.Close();
}
var response = request.GetResponse();
}
Getting Error 400 Bad Request in "request.GetResponse()".
I am able to create Account using same code. I don't Know what wrongs with Opportunity.