• John Brumbelow
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 6
    Replies

Please help.
We are trying to use the REST api with the "Lead" object in SFDC. Attempts to create a record all fail with a 400 error. We have been using the REST api with custom objects with great success but the Lead object does not work.
We are our account has full sys-admin to the Lead object, and we can run the developer console and run SoQL queries like this:
select Name, Number_of_Vehicles__c, Online_Pages_Completed__c, Title from Lead
The JSON for the post to create a Lead object is as such:
{
"Name":"Test Name",
"Number_of_Vehicles__c":0.0,
"Online_Pages_Completed__c":1.0,
"Title":"Test"
}
The 400 error returned give no reason why this fails. And we've even tried just { "Name": "Test Name" } and still get the 400,
Someone else has posted about having 400 with Lead object as well here:
 - https://developer.salesforce.com/forums#!/feedtype=SINGLE_QUESTION_DETAIL&dc=APIs_and_Integration&criteria=OPENQUESTIONS&id=906F00000005Hz1IAE
 - https://success.salesforce.com/answers?id=90630000000461VAAQ
But no one answered their post.
Their JSON differed in that they tried "FirstName" and "LastName" instead of "Name", but we tried it as well as such:
{"FirstName":"Test","LastName":"Name"}
We still got the 400 error.
How can we trouble shoot the 400 and fix this issue?
The documentation for using the REST-api's "ParameterizedSearch" has a BUG due to its flawed documentation and this flaw
withotu proper documentation can lead to a security risk.

Source of documentation:

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_search_parameterized.htm

Quote in documentation on the "q":
 - "A search string that is properly URL-encoded."
 - "SOSL clauses aren’t supported."
 - "Available in version 36.0 and later." 

BUG: Documentation does not explain this field correctly at all, and worse, the documentation goes on to using "q": "Acme", which if used, will cause all responses to be empty, unless your object happens to have "Acme" literally set in one or more of the fields of one or more of the records found.

To reproduce, follow the sample as-is in the documentation, including the "q": "Acme" sample, but ensure your object does not have any field of any record with "Acme" in it. The response will always be emtpy ==> [].

This is a security risk on top of the flawed documentation, as the "q" causes extra filtering, against ALL fields, and returns only those records with one or more fields that "contain" the "q" value similar to a LIKE statement similar to [ field like '%' + q + '%' ]. Because there is no documentation on "q" to explain this, and that "q" changes the returned data, across all fields similar to a LIKE '%q%', it is a security risk, if the "fields" is set to something that could trigger extra filtering.

Example of security risk:

if "fields" set to "Name" and "q" set to "Acme" from the below records, only 1st 3 would be returned:

   Name        Email
   Acme         MyEmail@Acme.com
   Acme.Google  MyEmail@Google.com
   Amazon.Acme  MyEmail@Amazon.com
   USPS         MyEmail@Acme.com

If "fields" is set to "Name", "Email", the return would now return the 4th row.
This is a security risk, as the documentation does not say anything about how "q" should do this.


 
Please help,

We are trying to use the ParameterizedSearch REST-api [ /services/data/v36.0/parameterizedSearch/ ].
We are getting a response of 400 (Bad Request) despite our efforts.
Can someone please inspect the code sample below, and point out what we are doing wrong.
Do note with the samepl code below, one must provide the Instance-Url and Access-Token from a valid login.

=================

HttpWebResponse hwrResponse = null;
StreamReader srResponse = null;

try
{
  string ParamSearchUrlExt = "/services/data/v36.0/parameterizedSearch/"; // <== I have tried 37 as well.

  string csUrl =
      " ~~~ InstanceUrl from Login ~~~ " +
      ParamSearchUrlExt +
      "";

  HttpWebRequest hwrRequest = WebRequest.Create(csUrl) as HttpWebRequest;
  hwrRequest.Method = "POST";
  hwrRequest.Headers.Add("Authorization", "Bearer " + " ~~ AccessToken from Login ~~ ");
  hwrRequest.ContentType = "application/json";
  hwrRequest.Proxy.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

  string csSearch =
  @"{
      ""q"": ""MySfdcObject__c"",
      ""defaultLimit"": ""100"",
      ""fields"":  [""Id"", ""Name"", ""SomeField__c"", ""SomeOtherField__c"", ""Attachments""],
      ""in"": ""ALL"",
      ""overallLimit"": ""100"",
      ""sobjects"":
      [
        {""name"": ""Name"", ""orderBy"": ""Name ASC NULLS_LAST"", ""where"": ""Name LIKE 'Test%'""},
        {""fields"": [""Id"", ""Name"", ""BodyLength"", ""Description"", ""ContentType""], ""name"": ""Attachments""}
      ]
  }";

  byte[] zbSearch = UTF8Encoding.UTF8.GetBytes(csSearch.ToString());
  hwrRequest.ContentLength = zbSearch.Length;

  using (Stream strSOQL = hwrRequest.GetRequestStream())
  {
    strSOQL.Write(zbSearch, 0, zbSearch.Length);
  }

  hwrResponse = hwrRequest.GetResponse() as HttpWebResponse; // <== fails... Returns 400...

}
catch (Exception e)
{
  // Hanld error...
}
finally
{
  if (!srResponse.IsNull())
  {
    ML.Ignore(() => srResponse.Close());
    ML.Ignore(() => srResponse.Dispose());
    srResponse = null;
  }

  if (!hwrResponse.IsNull())
  {
    ML.Ignore(() => hwrResponse.Close());
    ML.Ignore(() => hwrResponse.Dispose());
    hwrResponse = null;
  }
}
 
Please help.

We are a C#/.NET shop, and have been using SFDC with the WSDL api.
We want to use REST instead of the WSDL, where we would use C#/.NET code to call the SFDC-REST servers.
Can some one point us to simple, C#/.NET samples that accomplish the following tasks:

1) Create a SFDC object, using REST, given a C# string, that is in a JSON format for the object to create, and get back the
SFDC-ID after creating the SFDC object.

2) Same as (1) abiove, but create the SFDC object with a PDF, HTML-Text, and Binary File, set of attachments.

3) Update a SFDC object using REST, given a SFDC-ID.

4) Same as (3) but update the object to have new attachments, for a PDF, HTML-Text, and Binary File, set of attachments.

5) Same as (4), but in the update, remove any attachments.

6) Same as (4), but replace an existing attachment, given a file-name (or attachment name) to have something different.

7) Search for record(s) related to an SFDC object, given a SFDC-ID.

8) Search for record(s) related to an SFDC object, given key field information.

9) Same as (8), but using wild-card/partial search criteria, like search for all records where field X starts with "ABC", or
matches "A?B", or "A*B", etc.

 

Please help.
We are trying to use the REST api with the "Lead" object in SFDC. Attempts to create a record all fail with a 400 error. We have been using the REST api with custom objects with great success but the Lead object does not work.
We are our account has full sys-admin to the Lead object, and we can run the developer console and run SoQL queries like this:
select Name, Number_of_Vehicles__c, Online_Pages_Completed__c, Title from Lead
The JSON for the post to create a Lead object is as such:
{
"Name":"Test Name",
"Number_of_Vehicles__c":0.0,
"Online_Pages_Completed__c":1.0,
"Title":"Test"
}
The 400 error returned give no reason why this fails. And we've even tried just { "Name": "Test Name" } and still get the 400,
Someone else has posted about having 400 with Lead object as well here:
 - https://developer.salesforce.com/forums#!/feedtype=SINGLE_QUESTION_DETAIL&dc=APIs_and_Integration&criteria=OPENQUESTIONS&id=906F00000005Hz1IAE
 - https://success.salesforce.com/answers?id=90630000000461VAAQ
But no one answered their post.
Their JSON differed in that they tried "FirstName" and "LastName" instead of "Name", but we tried it as well as such:
{"FirstName":"Test","LastName":"Name"}
We still got the 400 error.
How can we trouble shoot the 400 and fix this issue?
Please help,

We are trying to use the ParameterizedSearch REST-api [ /services/data/v36.0/parameterizedSearch/ ].
We are getting a response of 400 (Bad Request) despite our efforts.
Can someone please inspect the code sample below, and point out what we are doing wrong.
Do note with the samepl code below, one must provide the Instance-Url and Access-Token from a valid login.

=================

HttpWebResponse hwrResponse = null;
StreamReader srResponse = null;

try
{
  string ParamSearchUrlExt = "/services/data/v36.0/parameterizedSearch/"; // <== I have tried 37 as well.

  string csUrl =
      " ~~~ InstanceUrl from Login ~~~ " +
      ParamSearchUrlExt +
      "";

  HttpWebRequest hwrRequest = WebRequest.Create(csUrl) as HttpWebRequest;
  hwrRequest.Method = "POST";
  hwrRequest.Headers.Add("Authorization", "Bearer " + " ~~ AccessToken from Login ~~ ");
  hwrRequest.ContentType = "application/json";
  hwrRequest.Proxy.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

  string csSearch =
  @"{
      ""q"": ""MySfdcObject__c"",
      ""defaultLimit"": ""100"",
      ""fields"":  [""Id"", ""Name"", ""SomeField__c"", ""SomeOtherField__c"", ""Attachments""],
      ""in"": ""ALL"",
      ""overallLimit"": ""100"",
      ""sobjects"":
      [
        {""name"": ""Name"", ""orderBy"": ""Name ASC NULLS_LAST"", ""where"": ""Name LIKE 'Test%'""},
        {""fields"": [""Id"", ""Name"", ""BodyLength"", ""Description"", ""ContentType""], ""name"": ""Attachments""}
      ]
  }";

  byte[] zbSearch = UTF8Encoding.UTF8.GetBytes(csSearch.ToString());
  hwrRequest.ContentLength = zbSearch.Length;

  using (Stream strSOQL = hwrRequest.GetRequestStream())
  {
    strSOQL.Write(zbSearch, 0, zbSearch.Length);
  }

  hwrResponse = hwrRequest.GetResponse() as HttpWebResponse; // <== fails... Returns 400...

}
catch (Exception e)
{
  // Hanld error...
}
finally
{
  if (!srResponse.IsNull())
  {
    ML.Ignore(() => srResponse.Close());
    ML.Ignore(() => srResponse.Dispose());
    srResponse = null;
  }

  if (!hwrResponse.IsNull())
  {
    ML.Ignore(() => hwrResponse.Close());
    ML.Ignore(() => hwrResponse.Dispose());
    hwrResponse = null;
  }
}
 
Please help.

We are a C#/.NET shop, and have been using SFDC with the WSDL api.
We want to use REST instead of the WSDL, where we would use C#/.NET code to call the SFDC-REST servers.
Can some one point us to simple, C#/.NET samples that accomplish the following tasks:

1) Create a SFDC object, using REST, given a C# string, that is in a JSON format for the object to create, and get back the
SFDC-ID after creating the SFDC object.

2) Same as (1) abiove, but create the SFDC object with a PDF, HTML-Text, and Binary File, set of attachments.

3) Update a SFDC object using REST, given a SFDC-ID.

4) Same as (3) but update the object to have new attachments, for a PDF, HTML-Text, and Binary File, set of attachments.

5) Same as (4), but in the update, remove any attachments.

6) Same as (4), but replace an existing attachment, given a file-name (or attachment name) to have something different.

7) Search for record(s) related to an SFDC object, given a SFDC-ID.

8) Search for record(s) related to an SFDC object, given key field information.

9) Same as (8), but using wild-card/partial search criteria, like search for all records where field X starts with "ABC", or
matches "A?B", or "A*B", etc.