vTiger webservice "ACCESS_DENIED : Permission to perform the operation is denied for id"

Kamil Kwiecien picture Kamil Kwiecien · Mar 20, 2013 · Viewed 7.7k times · Source

I want to add SalesOrder through vTiger webservice. I'm using for this vtwsclib. Here is the code:

<?php
include_once('vtwsclib/Vtiger/WSClient.php');
$url = 'http://localhost:8888';
$client = new Vtiger_WSClient($url);
$login = $client->doLogin('admin', 'zzzzzzzz');
if(!$login) echo 'Login Failed';
else {

    $data = array(
        'subject' => 'Test SalesOrder',
        'sostatus' => 'Created',
        'invoicestatus'=>'AutoCreated',
        'account_id'=> '46', // Existing account id
        'bill_street' => 'Bill Street',
        'ship_street' => 'Ship Street',
    );
    $record = $client->doCreate('SalesOrder', $data);

$error = $client->lasterror();
    if($error) {
    echo $error['code'] . ' : ' . $error['message'];
}

if($record) {
    $salesorderid = $client->getRecordId($record['id']);
}

}
?>

And I get only: "ACCESS_DENIED : Permission to perform the operation is denied for id".

Account_id exists in database. Other SalesOrder was added with the same account_id but through webpage. I have also tried variant with accout_id = "6x46" where 6 is module_id. It also didn't work. Any ideas how to solve this problem?

Answer

S.T.Prasad picture S.T.Prasad · Aug 3, 2013

I think you should be trying 11x46 for account id. Vtiger web services entity id's are different from tabids.

To get a correct list of all entity ids, execute this in your MySQL for the CRM:

select id, name from vtiger_ws_entity;