AnsweredAssumed Answered

Get Account Details from Contact through webservice APIs

Question asked by keshavkoncero on Feb 15, 2016

Hi Community,

 

I have a requirement, where I have the Contact Id, I need to retrieve the Account details like id, firstname, lastname.

Please suggest what which webservice should I use.

I was trying the get relationships API but getting an empty response..

 

XML:

<?xml version="1.0" encoding="utf-8"?>

<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://www.w3.org/2003/05/soap-encoding" xmlns:tns="http://www.sugarcrm.com/sugarcrm" xmlns:types="http://www.sugarcrm.com/sugarcrm/encodedTypes" xmlns:rpc="http://www.w3.org/2003/05/soap-rpc" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">

<soap12:Body soap12:encodingStyle="http://www.w3.org/2003/05/soap-encoding">

   <tns:get_relationships>

     <session xsi:type="xsd:string">lahvcnuigkhljsi4rtmnjmdp85</session>

     <module_name xsi:type="xsd:string">Contacts</module_name>

     <module_id xsi:type="xsd:string">903a7ae8-09f1-fbe9-039d-569fde69d270</module_id>

     <link_field_name xsi:type="xsd:string">accounts</link_field_name>

     <related_module_query xsi:type="xsd:string"></related_module_query>

     <related_fields soapenc:id="id0" soapenc:itemType="xsd:string" soapenc:arraySize="4">

       <Item  xsi:type="xsd:string">id</Item>

       <Item  xsi:type="xsd:string">first_name</Item>

       <Item  xsi:type="xsd:string">last_name</Item>

     </related_fields>

     <related_module_link_name_to_fields_array xsi:type="xsd:string">

       <Item  xsi:type="xsd:string">id</Item>

     </related_module_link_name_to_fields_array>

     <order_by xsi:type="xsd:string">date_entered desc</order_by>

     <offset xsi:type="xsd:int">0</offset>

     <max_results xsi:type="xsd:int">1</max_results>

     <deleted xsi:type="xsd:int">0</deleted>

   </tns:get_relationships>

</soap12:Body>

</soap12:Envelope>

 

 

 

Response:

<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://www.sugarcrm.com/sugarcrm"><SOAP-ENV:Body><ns1:get_relationshipsResponse xmlns:ns1="http://www.sugarcrm.com/sugarcrm"><return xsi:type="tns:get_entry_result_version2"><entry_list xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:entry_value[1]"><item xsi:type="tns:entry_value"><id xsi:nil="true" xsi:type="xsd:string" /><module_name xsi:type="xsd:string">Accounts</module_name><name_value_list xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:name_value[0]"></name_value_list></item></entry_list><relationship_list xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:link_list2[1]"><item xsi:type="tns:link_list2"></item></relationship_list></return></ns1:get_relationshipsResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>

 

Please help me resolve this issue. I understand this is a very simple requirement but I cant seem to figure how to get this sorted.

 

Thanks in Advance...

Outcomes