AnsweredAssumed Answered

How can I retrieve fields from related records in a REST filter POST request?

Question asked by Grant Schenck on Feb 14, 2019
Latest reply on Feb 15, 2019 by Grant Schenck

I'm using the filter endpoint to retrieve some fields from matching Contacts.  Specifically I'm doing a POST to the {URL}/rest/v11/Contacts/filter endpoint.  In the body I include the fields as follows:


"fields": "id,name,description"


That works great.


However, I also want to get the id and name of any accounts that are related to the retrieved contacts.  Per the help page for the filter GET request it seems like I should be able to.  Specifically, this page:… 


Shows in the example for the files field the following:


Example: name,account_type,description,{"name":"opportunities","fields":["id","name","sales_status"],"order_by":"date_closed:desc"} 


Note the bolded italics.  In this case it looks like the query would return details of related opportunities.  Based on this example I tried the following:


"fields": "id,name,phone_work,phone_mobile,phone_home,phone_other,description,{'name':'accounts','fields':['id','name']}"


But this only returns details of the contact and not of the related account.


I notice this similar posting for a couple of years ago (SugarCRM REST API - Filter POST - Related Module Fields ) so this seems like something tha#t Sugar needs to do a better job documenting.