vTiger Web服务:执行操作的权限被拒绝查询 [英] vTiger web services: Permission to perform the operation is denied for query

查看:141
本文介绍了vTiger Web服务:执行操作的权限被拒绝查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用vTiger Web服务检索包含查询的VtigerObjects数组.我正在按照此处给出的说明进行操作:

I'm using the vTiger web services to retreive an array of VtigerObjects containing my contacts using a query. I am following the instructions given here:

https://wiki.vtiger.com/index.php/Webservices_tutorials

到目前为止,我获得了可用于登录的质询令牌,因此可以正常工作.但是从我试图通过查询获取数据的那一刻起,我得到了以下错误:

So far I'm getting a challenge token which I can use to login, so that's working.. But from the moment i'm trying to get data with a query I get the following error:

拒绝执行该操作的查询"

"Permission to perform the operation is denied for query"

我是管理员,所以我应该拥有所有权限,对吗?这是我的代码,希望有人可以帮助我吗?

I'm the administrator, so I should have all the permissions, right? Here's my code, I hope someone can help me?

$username = 'xxxxxxxxxx';
$userAccessKey = 'xXxXxXxXxXxXxX';

//Create HTTP Client and set url and parameters
$client = new Zend_Http_Client();
$client->setUri('https://example.com/webservice.php');
$client->setParameterGet(array(
    'operation' => 'getchallenge', 
    'username' => $username
));

// Get Response (and decode)
$response = $client->request('GET');
$jsonResponse = Zend_Json::decode($response->getBody());

// Check if operation was successful
if ($jsonResponse['success'] == false)
    die('getchallenge failed:'.$jsonResponse['error']['errorMsg']);

// Get token from response
$challengeToken = $jsonResponse['result']['token'];


//create md5 string concatenating user accesskey from my preference page 
//and the challenge token obtained from get challenge result. 
$generatedKey = md5($challengeToken.$userAccessKey);

//Create HTTP Client and set url and parameters
$client->setUri('https://example.com/webservice.php');
$client->setParameterPost(array(
    'operation' => 'login',
    'username' => $username,
    'accessKey' => $generatedKey
), true);

// Get Response (and decode)
$response = $client->request('POST');
$jsonResponse = Zend_JSON::decode($response->getBody());

// Check if operation was successful
if($jsonResponse['success']==false)
    die('login failed:'.$jsonResponse['error']['errorMsg']);

$session = $jsonResponse['result']['sessionName'];


// Query to select contacts
$query = "select * from contacts";

// Urlencode the query
$encodedQuery = urlencode($query);

//Create HTTP Client and set url and parameters
$client->setUri('https://example.com/webservice.php');
$client->setParameterGet(array(
    'operation' => 'query',
    'sessionName' => $session,
    'query' => $encodedQuery
));

// Get Response (and decode)
$response = $client->request('GET');
$jsonResponse = Zend_JSON::decode($response->getBody());

// Check if operation was successful
if($jsonResponse['success']==false)
    die('query failed:'.$jsonResponse['errorMsg']);

// Return contacts
$retrievedObjects = $jsonResponse['result'];

推荐答案

不要对您的查询进行编码,只需执行以下操作:

Don't encode your query, just do this:

// Query to select contacts
$query = "select * from Contacts";

//Create HTTP Client and set url and parameters
$client->setUri('https://example.com/webservice.php');
$client->setParameterGet(array(
    'operation' => 'query',
    'sessionName' => $session,
    'query' => $query
));

我认为vTiger Web服务的官方文档是错误的.

I guess the official documentation for vTiger Web Services is wrong..

这篇关于vTiger Web服务:执行操作的权限被拒绝查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆