REST API Specification – Opportunities

Note: In all API calls, replace the % and example values between the % signs with your own variable values.

Get Opportunity

Replace %id% with the id of the opportunity that you want to retrieve, %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by the authentication process.

  • Description: Retrieve opportunity by id.
  • URL structure: http://zurmo_url/index.php/opportunities/opportunity/api/read/%id%
  • Method: GET
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Parameters: None
  • PHP sample:
    $authenticationData = login('super','super');
    //Add code to check if user is logged successfully
    
    $id = 1; // Change this with value of opportunity id
    
    $headers = array(
        'Accept: application/json',
        'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
        'ZURMO_TOKEN: ' . $authenticationData['token'],
        'ZURMO_API_REQUEST_TYPE: REST',
    );
    $response = ApiRestHelper::createApiCall('http://zurmo_url/index.php/opportunities/opportunity/api/read/' . $id, 'GET', $headers);
    // Decode json data
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        $opportunity = $response['data'];
        //Do something with opportunity
    }
    else
    {
        // Error, for example if we provided invalid opportunity id
        $errors = $response['errors'];
        // Do something with errors
    }
    
  • Return:
    Data contains opportunity info.

    {
      "status":"SUCCESS",
      "data":{
        "id":1,
        "createdDateTime":"2012-05-07 12:45:19",
        "modifiedDateTime":"2012-05-07 12:45:19",
        "createdByUser":{
          "id":1,
          "username":"super"
        },
        "modifiedByUser":{
          "id":1,
          "username":"super"
        },
        "owner":{
          "id":1,
          "username":"super"
        },
        "closeDate":"2011-01-01",
        "description":null,
        "name":"First Opportunity",
        "probability":0,
        "account":null,
        "amount":{
          "id":1,
          "value":500.54,
          "rateToBase":"1",
          "currency":{
            "id":1
          }
        },
        "stage":{
          "id":2,
          "value":"Negotiating"
        },
        "source":null
      },
      "message":null,
      "errors":null
    }
    

Delete Opportunity

Replace %id% with the id of opportunity that you want to delete, %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by the authentication process.

  • Description: Delete opportunity by id.
  • URL structure: http://zurmo_url/index.php/opportunities/opportunity/api/delete/%id%
  • Method: DELETE
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Parameters: None
  • PHP sample:
    $id = 1; // Change this value to opportunity id that you want to delete
    $authenticationData = login('super','super');
    //Add code to check if user is logged successfully
    
    $headers = array(
        'Accept: application/json',
        'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
        'ZURMO_TOKEN: ' . $authenticationData['token'],
        'ZURMO_API_REQUEST_TYPE: REST',
    );
    $response = ApiRestHelper::createApiCall('http://zurmo_url/index.php/opportunities/opportunity/api/delete/' . $id, 'DELETE', $headers);
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        // Inform user that opportunity is deleted
    }
    else
    {
        // Error, for example if we provided invalid opportunity id
        $errors = $response['errors'];
        // Do something with errors
    }
    
  • Return:
    {
      "status":"SUCCESS",
      "data":null,
      "message":null,
      "errors":null
    }
    

Create New Opportunity

Replace %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by authentication process.

  • Description: Create new opportunity
  • URL structure: http://zurmo_url/index.php/opportunities/opportunity/api/create/
  • Method: POST
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Parameters:
    $data = Array
    (
        [name] => Michael
        [closeDate] => 2002-04-03
        [probability] => 10
        [description] => Opportunity description
        ['source'] => Array
            (
                [value] => Outbound
            )
    
        [account] => Array
            (
                [id] => 1
            )
    
        [amount] => Array
            (
                [value] => 100
                [currency] => Array
                    (
                        [id] => 1
                    )
    
            )
    
        [stage] => Array
            (
                [value] => Negotiating
            )
    )
    
  • PHP sample:
    $authenticationData = login('super','super');
    //Add code to check if user is logged successfully
    
    $headers = array(
        'Accept: application/json',
        'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
        'ZURMO_TOKEN: ' . $authenticationData['token'],
        'ZURMO_API_REQUEST_TYPE: REST',
    );
    $data = Array
    (
        'name' => 'Michael'
        'closeDate' => '2002-04-03'
        'probability' => 10
        'description' => 'Opportunity description'
        'source' => Array
            (
                'value' => 'Outbound'
            ),
    
        'account' => Array
            (
                'id' => 1
            ),
    
        'amount' => Array
            (
                'value' => 100,
                'currency' => Array
                    (
                        'id' => 1,
                    )
    
            ),
    
        'stage' => Array
            (
                'value' => 'Negotiating',
            )
    );
    
    $response = ApiRestHelper::createApiCall('http://zurmo_url/index.php/opportunities/opportunity/api/create/', 'POST', $headers, array('data' => $data));
    $response = json_decode($response, true);
    
    if ($response['status'] == 'SUCCESS')
    {
        $opportunity = $response['data'];
        //Do something with opportunity data
    }
    else
    {
        // Error
        $errors = $response['errors'];
        // Do something with errors, show them to user
    }
    
  • Return:
    {
      "status":"SUCCESS",
      "data":{
        "id":2,
        "closeDate":"2002-04-03",
        "description":"Opportunity description",
        "name":"Michael",
        "probability":"10",
        "account":{"id":1},
        "amount":{
          "id":2,
          "value":"100",
          "rateToBase":"1",
          "currency":{
            "id":1
          }
        },
        "stage":{
          "id":3,
          "value":"Negotiating"
        },
        "source":{
          "id":4,
          "value":"Outbound"
        },
        "owner":{
          "id":1,
          "username":"super"
        },
        "createdDateTime":"2012-05-07 12:53:31",
        "modifiedDateTime":"2012-05-07 12:53:31",
        "createdByUser":{
          "id":1,
          "username":"super"
        },
        "modifiedByUser":{
          "id":1,
          "username":"super"
        }
      },
      "message":null,
      "errors":null
    }
    

Update existing opportunity

Replace %id% with the id of the opportunity that you want to update, %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by authentication process. Do note that if AutomaticProbabilityMapping is enabled in Opportunities module then user supplied probability values during update will be discarded.

  • Description: Update existing opportunity by id
  • URL structure: http://zurmo_url/index.php/opportunities/opportunity/api/update/%id%
  • Method: PUT
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Parameters:
    All parameters are optional, so you can only provide properties that you want to update.
    For example:

    $data = Array
    (
        'probability' => "15";
    )
    
  • PHP sample:
    $id = 1; // Change this value to oportunity id that you want to change
    $authenticationData = login('super','super');
    //Add code to check if user is logged successfully
    
    $headers = array(
        'Accept: application/json',
        'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
        'ZURMO_TOKEN: ' . $authenticationData['token'],
        'ZURMO_API_REQUEST_TYPE: REST',
    );
    // Change opportunity probability
    $data['probability'] = "15";
    $response = ApiRestHelper::createApiCall('http://zurmo_url/index.php/opportunities/opportunity/api/update/' . $id, 'PUT', $headers, array('data' => $data));
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        $opportunity = $response['data'];
        //Do something with opportunity data
    }
    else
    {
        // Error, for example if we provided invalid oportunity id
        $errors = $response['errors'];
        // Do something with errors
    }
    
  • Return:
    Code will return complete updated opportunity info.

    {
      "status":"SUCCESS",
      "data":{
        "id":2,
        "closeDate":"2002-04-03",
        "description":"Opportunity description",
        "name":"Michael",
        "probability":"15",
        "account":{"id":1},
        "amount":{
          "id":2,
          "value":"100",
          "rateToBase":"1",
          "currency":{
            "id":1
          }
        },
        "stage":{
          "id":3,
          "value":"Negotiating"
        },
        "source":{
          "id":4,
          "value":"Outbound"
        },
        "owner":{
          "id":1,
          "username":"super"
        },
        "createdDateTime":"2012-05-07 12:53:31",
        "modifiedDateTime":"2012-05-07 12:53:31",
        "createdByUser":{
          "id":1,
          "username":"super"
        },
        "modifiedByUser":{
          "id":1,
          "username":"super"
        }
      },
      "message":null,
      "errors":null
    }
    

Search opportunities

Replace %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by authentication process.

  • Description: Search opportunities
  • URL structure: http://zurmo_url/index.php/opportunities/opportunity/api/list/filter/%searchFilter%
  • Method: GET, POST
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Query parameters:
    $searchFilter = Array
    (
        [pagination] => Array
            (
                [page] => 1
                [pageSize] => 3
            )
        [search] => Array
            (
                [name] => Sample
                [owner] => Array
                    (
                        [id] => 1
                    )
            )
        [sort] => name.desc
    )
    
  • PHP sample:
    $authenticationData = login('super','super');
    //Add code to check if user is logged successfully
    
    $headers = array(
        'Accept: application/json',
        'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
        'ZURMO_TOKEN: ' . $authenticationData['token'],
        'ZURMO_API_REQUEST_TYPE: REST',
    );
    $searchParams = array(
        'pagination' => array(
            'page'     => 1,
            'pageSize' => 3,
        ),
        'search' => array(
            'owner' => array('id' => '1'),
        ),
        'sort' => 'name.desc',
    );
    // Get first page of results
    $searchParamsQuery = http_build_query($searchParams);
    $response = ApiRestTestHelper::createApiCall('http://zurmo_url/index.php/opportunities/opportunity/api/list/filter/' . $searchParamsQuery, 'GET', $headers);
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        // Do something with results
        if ($response['data']['totalCount'] > 0)
        {
            foreach ($response['data']['items'] as $item)
            {
            // Print opportunities
            }
        }
        else
        {
         // There are no opportunities
        }
    }
    else
    {
        $errors = $response['errors'];
        // Do something with errors
    }
    // Now get second page (you might wanted to check if there are results on second page first)
    $searchParams = array(
        'pagination' => array(
            'page'     => 2,
            'pageSize' => 3,
        ),
        'search' => array(
            'owner' => array('id' => '1'),
        ),
        'sort' => 'name.desc',
    );
    
    // Get second page of results
    $searchParamsQuery = http_build_query($searchParams);
    $response = ApiRestTestHelper::createApiCall('http://zurmo_url/index.php/opportunities/opportunity/api/list/filter/' . $searchParamsQuery, 'GET', $headers);
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        // Do something with results
        if ($response['data']['totalCount'] > 0)
        {
            foreach ($response['data']['items'] as $item)
            {
            // Print opportunities
            }
        }
        else
        {
         // There are no opportunities
        }
    }
    else
    {
        $errors = $response['errors'];
        // Do something with errors
    }
    
  • Return:
    {
      "status":"SUCCESS",
      "data":{
        "totalCount":"5",
        "currentPage":2,
        "items":[
          {
            "id":4,
            "createdDateTime":"2012-05-07 13:13:50",
            "modifiedDateTime":"2012-05-07 13:13:50",
            "createdByUser":{
              "id":1,
              "username":"super"
            },
            "modifiedByUser":{
              "id":1,
              "username":"super"
            },
            "owner":{
              "id":1,
              "username":"super"
            },
            "closeDate":"2011-01-01",
            "description":null,
            "name":"Second Opportunity",
            "probability":0,
            "account":{
              "id":2
            },
            "amount":{
              "id":4,
              "value":500.54,
              "rateToBase":"1",
              "currency":{
                "id":1
               }
             },
             "stage":{
               "id":11,
               "value":"Negotiating"
             },
             "source":null
           },
           {
             "id":5,
             "createdDateTime":"2012-05-07 13:13:50",
             "modifiedDateTime":"2012-05-07 13:13:50",
             "createdByUser":{
               "id":1,
               "username":"super"
             },
             "modifiedByUser":{
               "id":1,
               "username":"super"
             },
             "owner":{
               "id":1,
               "username":"super"
             },
             "closeDate":"2011-01-01",
             "description":null,
             "name":"Third Opportunity",
             "probability":0,
             "account":{
               "id":2
             },
             "amount":{
               "id":5,
               "value":500.54,
               "rateToBase":"1",
               "currency":{
                 "id":1
               }
             },
             "stage":{
               "id":12,
               "value":"Negotiating"
             },
             "source":null
           }
         ]
       },
      "message":null,
      "errors":null
    }
    

Opportunities Dynamic Search

Replace %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by authentication process.

  • Description: Dynamic search opportunities
  • URL structure: http://zurmo_url/index.php/opportunities/opportunity/api/list/filter
  • Method: GET, POST
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Query parameters:
    $data = Array
    (
        [dynamicSearch] => Array
            (
                [dynamicClauses] => Array
                    (
                        [0] => Array
                            (
                                [attributeIndexOrDerivedType] => owner
                                [structurePosition] => 1
                                [owner] => Array
                                    (
                                        [id] => 3
                                    )
    
                            )
    
                        [1] => Array
                            (
                                [attributeIndexOrDerivedType] => name
                                [structurePosition] => 2
                                [name] => Fi
                            )
    
                        [2] => Array
                            (
                                [attributeIndexOrDerivedType] => name
                                [structurePosition] => 3
                                [name] => Se
                            )
    
                    )
    
                [dynamicStructure] => 1 AND (2 OR 3)
            )
    
        [pagination] => Array
            (
                [page] => 1
                [pageSize] => 2
            )
    
        [sort] => name.asc
    )
    
    
  • PHP sample:
    $authenticationData = login('super','super');
    //Add code to check if user is logged successfully
    
    $headers = array(
        'Accept: application/json',
        'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
        'ZURMO_TOKEN: ' . $authenticationData['token'],
        'ZURMO_API_REQUEST_TYPE: REST',
    );
    $data = array(
        'dynamicSearch' => array(
            'dynamicClauses' => array(
            array(
                'attributeIndexOrDerivedType' => 'owner',
                'structurePosition' => 1,
                'owner' => array(
                    'id' => 3,
                ),
            ),
            array(
                'attributeIndexOrDerivedType' => 'name',
                'structurePosition' => 2,
                'name' => 'Fi',
            ),
            array(
                'attributeIndexOrDerivedType' => 'name',
                'structurePosition' => 3,
                'name' => 'Se',
            ),
            ),
            'dynamicStructure' => '1 AND (2 OR 3)',
        ),
        'pagination' => array(
            'page'     => 1,
            'pageSize' => 2,
        ),
        'sort' => 'name.asc',
    );
    // Get first page of results
    $response = ApiRestTestHelper::createApiCall('http://zurmo_url/index.php/opportunities/opportunity/api/list/filter/', 'POST', $headers, array('data' => $data));
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        // Do something with results
        if ($response['data']['totalCount'] > 0)
        {
            foreach ($response['data']['items'] as $item)
            {
            // Print opportunities
            }
        }
        else
        {
         // There are no opportunities
        }
    }
    else
    {
        $errors = $response['errors'];
        // Do something with errors
    }
    
  • Return:
    {
      "status":"SUCCESS",
      "data":{
        "totalCount":"5",
        "currentPage":2,
        "items":[
          {
            "id":4,
            "createdDateTime":"2012-05-07 13:13:50",
            "modifiedDateTime":"2012-05-07 13:13:50",
            "createdByUser":{
              "id":1,
              "username":"super"
            },
            "modifiedByUser":{
              "id":1,
              "username":"super"
            },
            "owner":{
              "id":1,
              "username":"super"
            },
            "closeDate":"2011-01-01",
            "description":null,
            "name":"Second Opportunity",
            "probability":0,
            "account":{
              "id":2
            },
            "amount":{
              "id":4,
              "value":500.54,
              "rateToBase":"1",
              "currency":{
                "id":1
               }
             },
             "stage":{
               "id":11,
               "value":"Negotiating"
             },
             "source":null
           },
           {
             "id":5,
             "createdDateTime":"2012-05-07 13:13:50",
             "modifiedDateTime":"2012-05-07 13:13:50",
             "createdByUser":{
               "id":1,
               "username":"super"
             },
             "modifiedByUser":{
               "id":1,
               "username":"super"
             },
             "owner":{
               "id":1,
               "username":"super"
             },
             "closeDate":"2011-01-01",
             "description":null,
             "name":"Third Opportunity",
             "probability":0,
             "account":{
               "id":2
             },
             "amount":{
               "id":5,
               "value":500.54,
               "rateToBase":"1",
               "currency":{
                 "id":1
               }
             },
             "stage":{
               "id":12,
               "value":"Negotiating"
             },
             "source":null
           }
         ]
       },
      "message":null,
      "errors":null
    }
    

Opportunities Improved Search

Replace %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by authentication process.

  • Description: Search opportunities – improved
  • URL structure: http://zurmo_url/index.php/opportunities/opportunity/api/search/filter
  • Method: GET, POST
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Query parameters:
    $data = Array
    (
        [search] => Array
            (
                [modelClassName] => Opportunity
                [searchAttributeData] => Array
                    (
                        [clauses] => Array
                            (
                                [1] => Array
                                    (
                                        [attributeName] => owner
                                        [relatedAttributeName] => id
                                        [operatorType] => equals
                                        [value] => 1
                                    )
                                [2] => Array
                                    (
                                        [attributeName] => name
                                        [operatorType] => startsWith
                                        [value] => Fi
                                    )
                                [3] => Array
                                    (
                                        [attributeName] => name
                                        [operatorType] => startsWith
                                        [value] => Se
                                    )
                            )
                        [structure] => 1 AND (2 OR 3)
                    )
            )
        [pagination] => Array
            (
                [page] => 1
                [pageSize] => 2
            )
        [sort] => name asc
    )
    
  • PHP sample:
    $authenticationData = login('super','super');
    //Add code to check if user is logged successfully
    
    $headers = array(
        'Accept: application/json',
        'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
        'ZURMO_TOKEN: ' . $authenticationData['token'],
        'ZURMO_API_REQUEST_TYPE: REST',
    );
    $data = array(
      'search' => array(
        'modelClassName' => 'Opportunity',
        'searchAttributeData' => array(
          'clauses' => array(
             1 => array(
               'attributeName'        => 'owner',
               'relatedAttributeName' => 'id',
               'operatorType'         => 'equals',
               'value'                => $userId,
             ),
             2 => array(
               'attributeName'        => 'name',
               'operatorType'         => 'startsWith',
               'value'                => 'Fi'
             ),
             3 => array(
               'attributeName'        => 'name',
               'operatorType'         => 'startsWith',
               'value'                => 'Se'
             ),
          ),
          'structure' => '1 AND (2 OR 3)',
        ),
      ),
      'pagination' => array(
        'page'     => 1,
        'pageSize' => 2,
      ),
      'sort' => 'name asc',
    );
    // Get first page of results
    $response = ApiRestTestHelper::createApiCall('http://zurmo_url/index.php/opportunities/opportunity/api/search/filter/', 'POST', $headers, array('data' => $data));
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        // Do something with results
        if ($response['data']['totalCount'] > 0)
        {
            foreach ($response['data']['items'] as $item)
            {
            // Print opportunities
            }
        }
        else
        {
         // There are no opportunities
        }
    }
    else
    {
        $errors = $response['errors'];
        // Do something with errors
    }
    
  • Return:
    {
      "status":"SUCCESS",
      "data":{
        "totalCount":"5",
        "currentPage":2,
        "items":[
          {
            "id":4,
            "createdDateTime":"2012-05-07 13:13:50",
            "modifiedDateTime":"2012-05-07 13:13:50",
            "createdByUser":{
              "id":1,
              "username":"super"
            },
            "modifiedByUser":{
              "id":1,
              "username":"super"
            },
            "owner":{
              "id":1,
              "username":"super"
            },
            "closeDate":"2011-01-01",
            "description":null,
            "name":"Second Opportunity",
            "probability":0,
            "account":{
              "id":2
            },
            "amount":{
              "id":4,
              "value":500.54,
              "rateToBase":"1",
              "currency":{
                "id":1
               }
             },
             "stage":{
               "id":11,
               "value":"Negotiating"
             },
             "source":null
           },
           {
             "id":5,
             "createdDateTime":"2012-05-07 13:13:50",
             "modifiedDateTime":"2012-05-07 13:13:50",
             "createdByUser":{
               "id":1,
               "username":"super"
             },
             "modifiedByUser":{
               "id":1,
               "username":"super"
             },
             "owner":{
               "id":1,
               "username":"super"
             },
             "closeDate":"2011-01-01",
             "description":null,
             "name":"Third Opportunity",
             "probability":0,
             "account":{
               "id":2
             },
             "amount":{
               "id":5,
               "value":500.54,
               "rateToBase":"1",
               "currency":{
                 "id":1
               }
             },
             "stage":{
               "id":12,
               "value":"Negotiating"
             },
             "source":null
           }
         ]
       },
      "message":null,
      "errors":null
    }
    

List Opportunity Attributes

Replace %sessionId% and %token% with ‘sessionId’ and ‘token’ variables returned by authentication process.

  • Description: List all opportunity attributes.
  • URL structure: http://zurmo_url/index.php/opportunities/opportunity/api/listAttributes
  • Method: GET
  • HTTP header parameters:
    Accept: application/json
    ZURMO_API_REQUEST_TYPE: REST
    ZURMO_SESSION_ID: %sessionId%
    ZURMO_TOKEN: %token%
  • Parameters: None
  • PHP sample
    $authenticationData = login('super','super');
    //Add code to check if user is logged successfully
    
    $headers = array(
        'Accept: application/json',
        'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'],
        'ZURMO_TOKEN: ' . $authenticationData['token'],
        'ZURMO_API_REQUEST_TYPE: REST',
    );
    $response = ApiRestHelper::createApiCall('http://zurmo_url/index.php/opportunities/opportunity/api/listAttributes', 'GET', $headers);
    // Decode json data
    $response = json_decode($response, true);
    if ($response['status'] == 'SUCCESS')
    {
        $opportunityAttributes = $response['data'];
        //Do something with opportunity attributes
    }
    else
    {
        // Error
        $errors = $response['errors'];
        // Do something with errors
    }
    
  • Return:
    Data contains opportunity attributes info.

Leave a Comment

  • Alex Osius

    Hey, we are trying to implement the opportunity functionality in our billing application.
    I want to create an opportunity like this example, but i just get an “FAILURE” message without any message or errors.

    the $data array:
    array(8) {
    ["name"]=>
    string(10) “Testchance”
    ["closeDate"]=>
    string(10) “2012-08-10″
    ["probability"]=>
    int(5)
    ["description"]=>
    string(4) “test”
    ["amount"]=>
    array(2) {
    ["value"]=>
    string(7) “1080.00″
    ["currency"]=>
    array(1) {
    ["id"]=>
    int(3)
    }
    }
    ["stage"]=>
    array(1) {
    ["value"]=>
    string(13) “Qualification”
    }
    ["source"]=>
    array(1) {
    ["value"]=>
    string(8) “Outbound”
    }
    ["account"]=>
    array(1) {
    ["id"]=>
    int(1)
    }
    }

    the call:
    $response = parent::apiCall(‘http://zurmo_url/index.php/opportunities/api/create/’, ‘POST’, $headers, array(‘data’ => $data));

    the $headers array is correct, because i can get the currencies to get the id for our currency.

    Do you have some tipps why it isn’t working or what am i doing wrong?

    Thanks in advance.
    Alex

    • Ivica Nedeljkovic

      I asked for additional details in your forum thread.

    • http://www.facebook.com/people/Ray-Stoeckicht/100001473956853 Ray Stoeckicht

      Alex, are you and Timo working together? He posted the same content on our forums:
      http://zurmo.org/forums/index.php?/topic/219-api-create-opportunity-failure/

    • Ewin Barnett

      Here is the class for the authorize response. This response appears to be constant in format, so we can use a class to describe it. Other responses are variable, so they have to be dynamically decoded. Again, please excuse the way this looks on Disqus.

      package com.adnorm.sandbox.crm;

      import com.google.gson.annotations.SerializedName;

      // Class for response to REST API Authorize

      // {“status”:”SUCCESS”,”data”:{“sessionId”:”jh4d8kbiqe2i7gsbkj09h67g17″,”token”:”1b0116826aa823ea9bff961de146cf88″},”message”:null,”errors”:null}

      public class ZurmoAPIAuthorize {

      private ZAPIAuthorizeResponse ZARresponse;

      class ZAPIAuthorizeResponse {

      String status;

      private DataResponse dataResponse;

      String message;

      String errors;

      public String getStatus() {

      return status;

      }

      public DataResponse getDataResponse() {

      return dataResponse;

      }

      public String getMessage() {

      return message;

      }

      public String getErrors() {

      return errors;

      }

      @Override

      public String toString() {

      return “ZAPIAuthorizeResponse [status=" + status

      + ", dataResponse=" + dataResponse + ", message=" + message

      + ", errors=" + errors + "]“;

      }

      }

      static class DataResponse {

      String sessionId;

      String token;

      public String getSessionId() {

      return sessionId;

      }

      public String getToken() {

      return token;

      }

      @Override

      public String toString() {

      return “DataResponse [sessionId=" + sessionId + ", token=" + token

      + "]“;

      }

      }

      @Override

      public String toString() {

      return “ZurmoAPIAuthorize [ZARresponse=" + ZARresponse + "]“;

      }

      }

  • Haqeem Luqman

    Sorry sir, in my Zurmo i want to connect Opportunity Module to my PMO Application Project then, if Opprty was Accepted to Be A Project in PMO, then file in Opprty will be moved into Project CRM too, so File opprty that accepted will be project, what should i do sir ?

    Thank You
    Haqeem

    • Haqeem Luqman

      i mean, i was really confused in API sir, if want get the file opprty from database, what i’ve to change in Project Module Zurmo/CRM

      • Haqeem Luqman

        Hepl sir :’(