-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement addLead
#174
base: master
Are you sure you want to change the base?
Implement addLead
#174
Conversation
- fix bug on try receive Lead with null person_id - use `JObject` in `Create` operation, to remove null values from Body
@@ -9,10 +9,13 @@ namespace Pipedrive | |||
/// </summary> | |||
/// <remarks> | |||
/// See the <a href="https://developers.pipedrive.com/docs/api/v1/Leads">Lead API documentation</a> for more information. | |||
/// </remarks> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Bugfix: This XML docs don't work because close tag missing.
{ | ||
Ensure.ArgumentNotNull(data, nameof(data)); | ||
|
||
return ApiConnection.Post<LeadCreated>(ApiUrls.Leads(), JObject.FromObject(data)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using JObject.FromObject
construction to handle null values.
Without null values handling receive error like:
{
"success":false,
"data":null,
"additional_data":null,
"error":"provided dataset is not valid",
"error_info":"\"owner_id\" must be a number"
}
Example of request:
var data = new NewLead("Lead created from C#")
{
OrganizationId = 1
};
var createdLead = await client.Lead.Create(data);
[JsonProperty("person_id")] | ||
public long PersonId { get; set; } | ||
public long? PersonId { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added null possible for person_id
because, this value can be null. And we receive JsonSerialization exception on try set null in not-nullable PersonId
Exception:
Unhandled exception. Newtonsoft.Json.JsonSerializationException: Error converting value {null} to type 'System.Int64'. Path 'person_id'
[JsonProperty("visible_to")] | ||
public string VisibleTo { get; set; } | ||
|
||
[JsonProperty("cc_email")] | ||
public string CcEmail { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added missing fields
No description provided.