Results 1 to 2 of 2

Thread: How to Add Relationship Through Rest In SugarCRM

  1. #1
    madhusudan2291 Guest

    Default How to Add Relationship Through Rest In SugarCRM

    I am using one-to-many relationship between Contact And CountryCity Module And I need to add a relationship to this using REST,

    I have used following code to create a relationship between these two


    $url = "localhost/RealEstateAgentCRM/service/v4/rest.php";

    $username = "admin";
    $password = "admin";
    function call($method, $parameters, $url)
    $curl_request = curl_init();
    curl_setopt($curl_request, CURLOPT_URL, $url);
    curl_setopt($curl_request, CURLOPT_POST, 1);
    curl_setopt($curl_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
    curl_setopt($curl_request, CURLOPT_HEADER, 1);
    curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl_request, CURLOPT_FOLLOWLOCATION, 0);
    $jsonEncodedData = json_encode($parameters);
    $post = array(
    "method" => $method,
    "input_type" => "JSON",
    "response_type" => "JSON",
    "rest_data" => $jsonEncodedData
    curl_setopt($curl_request, CURLOPT_POSTFIELDS, $post);
    $result = curl_exec($curl_request);
    $result = explode("\r\n\r\n", $result, 2);
    $response = json_decode($result[1]);
    return $response;
    $login_parameters = array(
    $login_result = call("login", $login_parameters, $url);
    $session_id = $login_result->id;

    $parameters = array(
    'session' => $session_id,
    'module_id' => '3671da49-2d13-aa21-7h49-519b11dgu34', // This is a contact Id
    'module_name' => 'Contacts',
    'link_field_name' => 'contacts_veon_country_city_list_1',
    'related_ids' => array('3904da49-2d13-aa21-72a9-519b11d43b02'), // This is a City-Country id

    $add_relationship_result = call("set_relationship", $parameters, $url);



    Madhusudan Singh

  2. #2
    madhusudan2291 Guest

    Default Re: How to Add Relationship Through Rest In SugarCRM

    I had also tried REST Examples From this link IBM notice: The page you requested cannot be displayed
    but still its not working i am getting following error if I use the codes mention in the above link

    Warning: curl_exec() expects parameter 1 to be resource,

    Madhusudan Singh

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help: Javascript Rest Sugarcrm
    By chrisandrews in forum Developer Help
    Replies: 0
    Last Post: 2013-04-28, 07:17 PM
  2. Insert Records In Relationship table Using REST
    By madhusudan2291 in forum Developer Help
    Replies: 4
    Last Post: 2013-03-23, 04:44 AM
  3. Insert a many to many relationship with REST API
    By Shot89 in forum Developer Help
    Replies: 6
    Last Post: 2012-04-16, 09:24 PM
  4. Replies: 0
    Last Post: 2012-02-15, 08:51 AM
  5. Rest Api Of SugarCRM
    By karan5037 in forum General Discussion
    Replies: 0
    Last Post: 2009-10-21, 06:27 AM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts