How to get all contacts property values using API?

I want to select multiple properties and get contact.

I call this API URL

/contacts/v1/lists/1/contacts/all?hapikey=MY_API_KEY&count=1&property=firstname&property=lastname

It return contacts properties

"properties"=>{"lastmodifieddate"=>{"value"=>"999999999"}, "lastname"=>{"value"=>"test"}},

The first property firstname is missing.

Is it possible to specify multiple properties?

Hello @Akinov

The API endpoint that you are using is correct. The main point here is that even if we specify the property name to fetch the values, the contacts who do not have any value will not contain that property in the response.

Next the response ( when no property is speciffied in the URL ) contains a standard set of properties. To get value for multiple properties, you can use &property=X parameter multiple times.

Thanks

@himanshurauthan

Thanks for the advice!

I tried it, but multiple properties were not returned in my environment…

Try API URL

/contacts/v1/lists/1/contacts/all?hapikey=MY_API_KEY&count=1&property=email&property=lastname

Returned properties is only lastname

"properties"=>{"lastmodifieddate"=>{"value"=>"1567479732814"}, "lastname"=>{"value"=>"test name"}},

>The main point here is that even if we specify the property name to fetch the values, the contacts who do not have any value will not contain that property in the response.

I checked property contain

Try1

/contacts/v1/lists/1/contacts/all?hapikey=MY_API_KEY&count=1&property=email

Returned1

"properties"=>{"lastmodifieddate"=>{"value"=>"1567479732814"}, "email"=>{"value"=>"MY_EMAIL"}},

Try2

/contacts/v1/lists/1/contacts/all?hapikey=MY_API_KEY&count=1&property=lastname

Returned2

"properties"=>{"lastmodifieddate"=>{"value"=>"1567479732814"}, "lastname"=>{"value"=>"test name"}},

returned contacts vid is same.

Is the property specification method incorrect?

Still stuck on the same problem.

Please let me know if there is a solution.

Hello @Akinov

Sorry for the delay. Everything that you are trying is right but the way to get email of a contact. The email of a contact is not treated as property but as identity of the record. You will find the email of the contact in a seperate parameter of response i.e. identity-profiles . In this we have, contact vid, email etc.

Thanks.

Hello @himanshurauthan

Thanks you!

I try it!

@Akinov

Glad to know if it worked for you. Please Accept it as a Solution if my reply helped you.

Thanks.

@himanshurauthan

Thank you for your support.

I tried it with my own property.

( `grade` & `tsukulink_status` . These two are the things that contacts always have)

Confirmed that the contact has a `grade` property

# call url(property=grade)/contacts/v1/lists/1/contacts/all?hapikey=#{hapikey}&count=1&property=grade# returned full json (id, token, xxAt is dummy){"contacts"=> [{"addedAt"=>111111, "vid"=>1111, "canonical-vid"=>1111, "merged-vids"=>[], "portal-id"=>111111, "is-contact"=>true, "profile-token"=>"token", "profile-url"=>"url", "properties"=>{"lastmodifieddate"=>{"value"=>"111111"}, "grade"=>{"value"=>"basic"}}, "form-submissions"=> [], "identity-profiles"=> [{"vid"=>1111, "saved-at-timestamp"=>111111, "deleted-changed-timestamp"=>0, "identities"=> [{"type"=>"LEAD_GUID", "value"=>"guid", "timestamp"=>111111}, {"type"=>"EMAIL", "value"=>"mail@mail", "timestamp"=>111111, "is-primary"=>true}]}, {"vid"=>111111, "saved-at-timestamp"=>111111, "deleted-changed-timestamp"=>0, "identities"=>[]}], "merge-audits"=>[]}], "has-more"=>true, "vid-offset"=>1111}

Confirmed that the contact has a `tsukulink_status` property

# call url(property=tsukulink_status)
/contacts/v1/lists/1/contacts/all?hapikey=#{hapikey}&count=1&property=tsukulink_status

# returned full json
{"contacts"=>
 [{"addedAt"=>111111,
 "vid"=>1111,
 "canonical-vid"=>1111,
 "merged-vids"=>[],
 "portal-id"=>111111,
 "is-contact"=>true,
 "profile-token"=>"token",
 "profile-url"=>"url",
 "properties"=>{"lastmodifieddate"=>{"value"=>"111111"}, "tsukulink_status"=>{"value"=>"active"}},
 "form-submissions"=> [],
 "identity-profiles"=>
 [{"vid"=>1111,
 "saved-at-timestamp"=>111111,
 "deleted-changed-timestamp"=>0,
 "identities"=>
 [{"type"=>"LEAD_GUID", "value"=>"guid", "timestamp"=>111111},
 {"type"=>"EMAIL", "value"=>"mail@mail", "timestamp"=>111111, "is-primary"=>true}]},
 {"vid"=>21025120, "saved-at-timestamp"=>111111, "deleted-changed-timestamp"=>0, "identities"=>[]}],
 "merge-audits"=>[]}],
 "has-more"=>true,
 "vid-offset"=>1111}

I tried an API request that uses two properties

# call url(property=tsukulink_status&property=grade)
/contacts/v1/lists/1/contacts/all?hapikey=#{hapikey}&count=1&property=tsukulink_status&property=grade

# returned full json
{"contacts"=>
 [{"addedAt"=>111111,
 "vid"=>1111,
 "canonical-vid"=>1111,
 "merged-vids"=>[],
 "portal-id"=>111111,
 "is-contact"=>true,
 "profile-token"=>"token",
 "profile-url"=>"url",
 "properties"=>{"lastmodifieddate"=>{"value"=>"111111"}, "grade"=>{"value"=>"basic"}},
 "form-submissions"=> [],
 "identity-profiles"=>
 [{"vid"=>1111,
 "saved-at-timestamp"=>111111,
 "deleted-changed-timestamp"=>0,
 "identities"=>
 [{"type"=>"LEAD_GUID", "value"=>"guid", "timestamp"=>111111},
 {"type"=>"EMAIL", "value"=>"mail@mail", "timestamp"=>111111, "is-primary"=>true}]},
 {"vid"=>111111, "saved-at-timestamp"=>111111, "deleted-changed-timestamp"=>0, "identities"=>[]}],
 "merge-audits"=>[]}],
 "has-more"=>true,
 "vid-offset"=>1111}

The returned properties included only the last specified property…

@Akinov

Can you please make sure the contcat GET response examples that you have quoted in your last reply are the exact ones? I can see that some of the values are edited there. Can you confirm the response of all the 3 calls ( grade, tsukulink_status, grade & tsukulink_status both ) on behalf of the contact VID? Just want to make sure that in all these 3 calls you are getting the same contact each time.

@himanshurauthan

Thanks for reply!

All three calls returned the same contact(vid) every time.

@himanshurauthan

thank you for your support.

It was solved thanks to you.

It seems that Faraday of the HTTP client I was using automatically removes duplicate parameters and requests them from the API…