Problem with the contacts endpoint regarding "related_contacts" - clio-api

I have a problem with the contacts endpoint regarding related_contacts.
I'm trying to make this request:
https://app.clio.com/api/v4/contacts.json?fields=id,name,first_name,last_name,type,primary_email_address,primary_phone_number,is_client,activity_rates{rate,flat_rate},addresses{name,street,city,province,postal_code,country},custom_field_values{id,field_type,field_name,value,custom_field},phone_numbers{name,number,default_number},web_sites{name,address,default_web_site},account_balances{name,type,balance},related_contacts{id,type,name,first_name,last_name,primary_email_address,primary_phone_number,is_client},primary_work_address{name,street,city,province,postal_code,country},company{id,type,name,first_name,last_name,primary_email_address,primary_phone_number,is_client},payment_profile{id,name,terms,discount_rate,discount_period,interest_rate,interest_period,interest_type},co_counsel_rate{id,rate,flat_rate,contact_id,co_counsel_contact_id},primary_web_site{name,address,default_web_site},created_at,updated_at&type=Company&client_only=true&order=name(asc)&limit=200
But it fails. If I remove the related_contacts{} part, it works. If I add back so much as related_contacts{id} it fails.
Has anyone else run into this?

I don't think this exactly answers your question, but I've been struggling with the same thing and as best I can tell, related_contacts is a dead-end in the API.
The real answer I think is not to use related_contacts at all, instead use the relationships endpoint. If you log on to the Clio portal and look at "Related contacts" under matter, this is actually the call that it's making.
You could call all relationships as you calling all contacts in your sample, but it's probably much more useful to include either the matter_id or contact_id as part of the query string to get relationships specific to one or the other.

Related

Google MyBusinessInformation API, where are the services?

I'm stuck with the BusinessInformation API, actually I can add custom categories and services bound to it in the Google MyBusiness interface, but I'm still trying to figure out how to do the same using the API.
So far I found the way to get all the categories here, but I'd like to only get the categories that are bound with my current location.
Then about the services bound to each category, I couldn't figure it out what I only got similar is that link but it's deprecated.
Does someone know the way to do this?
Best
Sorry for this, actually it's OBVIOUS: those are attributes of the Location object.
I'll leave this here though, just in case that someone falls in the same trap.

Getting all related Contact for an Account entity in Dynamics 365 CRM v9.0 web api

Basically, I'm querying the D365 web API and I'm trying to get all of the related contacts for an account.
Been following this link:
https://learn.microsoft.com/en-us/dynamics365/customer-engagement/developer/webapi/query-data-web-api#retrieve-related-entities-by-expanding-navigation-properties
Trying to use $expand but it only will bring over _primarycontactid_value. So just the one primary contact and not everyone that is related to the Account.
It would look something like the following:
/api/data/v9.0/accounts&?select=name&$expand=Contacts(fullname, email)
The only fields in Account that have "contact" in them are:
preferredcontactmethodcode
_primarycontactid_value
address2_primarycontactname
address1_primarycontactname
_tcc_primaryinvoicecontactid_value
_tcc_consultingcontact_value
_tcc_contactlist_value //some custom field that doesn't apparently do anything
_new_foundationcontact_value
_tcc_primaryapcontactid_value
So none of which can be used to look-up all of the contacts... that I know of.
Another way to do it would be to start with the Contact first and then $expand= on the _parentcustomerid_value. But I need to filter on the Account to specify certain accounts that I want... this would just bring over every account and be incredibly slow. I'm not sure there is a way to $filter= on an $expand= value.
So:
How can I query the Account and all the related to Contacts for an Account?
If there is no way, is it possible to use $filter= on and $expand= value?
Trying to keep the amount of queries to a minimum. This could be solved by doing multiple iterative queries, but that will just make it incredibly slow. Or just query everything and piece it together, but that will be slow as well.
Ok, stumbled across the answer: contact_customer_accounts.
Query ends up looking like the following: /api/data/v9.0/accounts&?select=name&$expand=contact_customer_accounts($select=fullname).
As far as I can tell, custom relationships can be used as well, although I have only tested with 1:N types.
Still takes a little while to generate, but works.

Restful resource naming for "secondary" tables

Let's go with my example, I have 3 tables and I want to know what's the best method to name my resource url.
Tables:
building
building_type The most simple to define is #1.
API resources:
GET someapi.com/buildings
GET someapi.com/**?**
My problem is that I don't know what's the best practice for "secondary tables" like building_type.
Maybe:
GET someapi.com/buildings/types
GET someapi.com/building-types
...
I hope some of you will reach to enlighten me. Thanks.
You first need to figure our the requirements for your API, the scenarios, use cases etc, and only then actually start building it.
To go back to your question, I'd go for GET someapi.com/buildingTypes, because /buildings/types will leave you with a "Types" resource which doesn't make much sense on it's own. You could indeed make it so it's only accessible once you go to the buildings resource, so GET someapi.com/buildings/buildingTypes could be the way to navigate to it.

RESTful - GET or POST - what to do?

Im working on a web service that i want to be RESTful. I know about the CRUD way of doing things, but I have a few things that im not completly clear with. So this is the case:
I have a tracking service that collects some data in the browser (client) and then sends it off to the tracking server. There are 2 cases, one where the profile exists and one where it does not. Finally the service returns some elements that has to be injected to the DOM.
So basically i need 2 web services:
http://mydomain.tld/profiles/
http://mydomain.tld/elements/
Question 1:
Right now im only using GET, but im rewriting the server to support CRUD. So in that case i have to use POST if the profile does not exist. Something like http://mydomain.tld/profiles/ and then POST payload have the information to save. If the profile is existing i use PUT and http://mydomain.tld/profiles// and payload of PUT has data to save. All good, but problem is that as far as i understand, xmlhttp does not support PUT. Now is it ok to use POST even though its an update?
Question 2:
As said my service returns some elements to be injected into the DOM, when a track is made. Logically, to keep it RESTful, i guess that i would have to use POST/PUT to update the profile and then GET to get the elements to inject. But to save bandwidth and resources on the serverside, it makes more sense to return the elements with the POST/PUT to profiles, even though its a different resource. What are your take on this?
BR/Sune
EDIT:
Question 3:
In some cases i only want to update the profile and NOT receive back elements. Could i still use same resource and then using a payload parameter to specify if i want elements, e.g. "dont_receive_elements:true"
On question #1, are you sure that xmlhttp does not support "put"? I just ran http://www.mnot.net/javascript/xmlhttprequest/ on three browsers (Chrome, Firefox, IE) and according to the output, "put" was successful on all browsers. Following the information on http://www.slideshare.net/apigee/rest-design-webinar (and I highly recommend checking out the many Apigee videos and slideshows on restful API), "put" is recommended for the use case you mention.
But you may be able to avoid this issue entirely by thinking a little differently about your data. Is it possible to consider that you have a profile and that for each profile you have 0 or more sets of payload information? In this model the two cases are:
1. No profile exists, create profile with a POST on .../profiles/ Then add elements/tracking data with posts to .../profile/123/tracks/ (or .../profile/123/elements/)
2. Profile exists, just add the elements/tracking data
(Sorry without understanding your model in detail, it is hard to be very precise).
As for question #2 - going with a data model where a profile has 0 or more elements, you could update the profile (adding the necessary elements) and then return the updated profile (and its full graph of elements), saving you any additional gets.
More generally on question #2, as the developer of the API you have a fair amount of freedom in the REST world - if you are focused on making it easy and obvious for the consumers of your API then you are probably fine.
Bottom line: Check out www.apigee.com - they know much more than I.
#Richard - thanks alot for your links and feedback. The solution i came down to is to make the API simple and clean as you suggest in your comment, having seperate calls to each resouce.
Then to be able to save bandwidth and keep performance up, I made a "non-official" function in the API that works like a proxy internally and are called with a single GET, that updates a profile and returns an element. This, i know, is not very restful etc, but it handles my situation and is not part of the official API. The reason i need it to support GET for this i need to call it from javascript and cross domain.
I guess i could have solved the cross domain by using JSONP, but i would still have to make the API "unclean" :)

Method to allow email recipients to change their account information

I'm using SugarCRM Community Edition. I have a bunch of contact information. There are fields I have empty that would like filled. I want each user to be able to fill out a form and fill in those fields.
I'm not sure how to hook each contact into the database. I imagine creating a generic form that somehow hooks into the database using a key. The form/php is not the issue. What is the 'key' and where is the 'door'? I think the door is the SOAP API but I'm not sure. The key, maybe the tracker id?
The only thing I am familiar with as far as interaction between an email campaign and the contact is the campaign 'Tracker'. I know the tracker url with removeme is used for allowing the user to opt out of emails. Is there a way to use this tracker to allow the person to edit their information? I think the answer to this is easy but I need some guidance.
One way of doing this is using the built-in REST api. There are a couple of helpful tutorials out there, here is a link to the one I used for guidance in a similar situation.
You can have a form post the data to your sugar crm's REST gateway, accessible via the url http://localhost/sugar/v2/rest.php.
Although it is quite straightforward to implement, you may want to look at this wrapper class that can be used to maybe keep things cleaner than the hacked up script churned out on the spur of the moment I used in my project.
Last but not least, be sure to glance over the documentation, in the Web Services section you will find more information.
Good-luck