6
To use PATCH, you need to make sure you're encoding the ID. Assuming the URL in your question was generated literally, that's problematic. The URL should look like:
/services/data/v41.0/sobjects/Product2/ProductID__c/%23%20H6%20SHORT%20BARREL%20NUT
Characters other than A-Z, 0-9, #, and _ need to be URL-encoded. As it was, the URL was written in a way that ...
2
There is no MailingAddress on a Person Account (Account), the addresses are PersonMailingStreet, PersonMailingCity, etc
On a person Account only the BillingStreet, BillingCity, etc are available
Just in case
Compound fields are read-only. To update field values, modify the
individual field components.
You need to update the individual components:
...
2
The following console application ran for me and created the ResourceView__c record associated with the Lead.
Note that:
The Lead Id was assigned as a string.
I needed to add my namespace prefix of "DFB__" to the types.
Full console app:
class Program
{
static void Main(string[] args)
{
Task.Run(async () =>
{
...
answered Jun 22 '16 at 23:59
Daniel Ballinger
93.6k2424 gold badges213213 silver badges507507 bronze badges
2
In Salesforce, record Id's are generated when you insert any record. Once record id's are generated they become Read Only fields. Hence they cannot be modified.
In above code, you're trying to make id field of contact to null. Now consider a RDBMS case, were you're trying to make Primary key as a null. This is a invalid scenario because primary key cannot ...
2
Lets go down the rabbit hole!
ForceClient.QueryAsync
JsonHttpClient.HttpGetAsync
BaseHttpClient.HttpGetAsync
protected async Task<string> HttpGetAsync(Uri uri)
{
var responseMessage = await HttpClient.GetAsync(uri).ConfigureAwait(false);
// ...
}
If you were using the toolkit source directly rather than via nuget you could just grab the ...
answered Sep 7 '17 at 0:02
Daniel Ballinger
93.6k2424 gold badges213213 silver badges507507 bronze badges
1
Have a look at how UpdateAsync is implemented with respect to the underlying REST API. It maps the record ID into the PATCH URL.
Yet your anonymous type includes an Id property, even if it is null.
Try something like:
var auth = new AuthenticationClient();
await auth.UsernamePasswordAsync(ConsumerKey, ConsumerSecret, Username, Password);
ForceClient ...
answered Jun 20 '17 at 1:19
Daniel Ballinger
93.6k2424 gold badges213213 silver badges507507 bronze badges
1
I was able to get this to work by commenting out line 65 in the c# code.
request.Headers.UserAgent.ParseAdd(string.Concat(UserAgent, "/", ApiVersion));
This line sets the UserAgent to the API Version 36.
Edit:
I added that line back in and removed the Variables and set them to strings of forcedotcom-toolkit-dotnet and v36.0.
This worked for me. Check to ...
1
After reading the other answers and reviewing my code again I found the answer staring me in the face. The second error message was the key
Lead: id value of incorrect type: 0035800000AQqGfAAL
Turns out this ID was a Contact ID, not a Lead ID. I had assumed this error meant string was the wrong type but no, it meant I was trying to pass a Contact into a ...
1
One option would be to create new objects with just the fields you want to update.
You could either use strongly typed POCO or annonymous types.
E.g.
// annonymous types
var success = await client.UpdateAsync("Lead", lead.Id, new { Name = "Test Update" });
answered Mar 9 '16 at 19:50
Daniel Ballinger
93.6k2424 gold badges213213 silver badges507507 bronze badges
1
There are examples of creating records using the Force.com Toolkit for .NET in Nothing But .Net – Implementing CRUD Operations.
You will want something like:
public class Lead {
public string Id { get; set; }
public string LastName { get; set; }
public string Company { get; set; }
}
// ...
// Get the client based on your chosen authentication ...
answered May 11 '15 at 22:42
Daniel Ballinger
93.6k2424 gold badges213213 silver badges507507 bronze badges
Only top voted, non community-wiki answers of a minimum length are eligible
Related Tags
force.com-toolkit-for-net × 15.net × 10
c# × 7
rest-api × 4
leads × 2
integration × 1
force.com × 1
picklist × 1
oauth × 1
httpresponse × 1
sdk × 1