Diego Mattos
Diego Mattos

Reputation: 1

vTiger webservice update operation

im trying to do an update operation from angular 2 but i dont know how to pass the element parameter

in the vtigercrm.log i see DEBUG webservice -

array ('element' => NULL)

which leads to this

"error": {
"code": "ACCESS_DENIED",
"message": "Permission to perform the operation is denied for id",

i tryied passing the following object as a JSON

{
"subject":"test2",
"assigned_user_id":"19x1",
"date_start":"2016-11-15",
"time_start":"12:00:00",
"due_date":"2016-11-15",
"time_end":"14:00:00",
"recurringtype":"",
"duration_hours":"2",
"duration_minutes":"0",
"parent_id":"",
"eventstatus":"Planned",
"sendnotification":"0",
"activitytype":"Call",
"location":"",
"createdtime":"2016-11-15 11:31:19",
"modifiedtime":"2016-11-15 11:31:19",
"taskpriority":"",
"notime":"0",
"visibility":"Public",
"modifiedby":"19x1",
"description":"",
"reminder_time":"",
"contact_id":"",
"latitud":"",
"longitud":"",
"id":"18x22029"
}

the same thing as encodeURI and encodeURIComponent but nothing works

Upvotes: 0

Views: 1555

Answers (2)

NoelHunter
NoelHunter

Reputation: 996

I had a similar error, and I found a subtle difference in the JSON. When a result was returned, the json object is the first element in an array. But for sending, it needs to be just the object, not an array.

<?php

//decode the json encode response from the server.
$jsonResponse = json_decode( $response->getBody(), true );

//Get first array element for sending back with update			
$objectJson = json_encode($jsonResponse[ 'result' ][0]);
				
?>

Whenever I tried sending the original response, I received an error: {"success":false,"error":{"code":"ACCESS_DENIED","message":"Permission to perform the operation is denied for id"}}

Upvotes: 1

Jeremie
Jeremie

Reputation: 1018

This error message can be due to:

  1. Object ID not mentionned/correct in the JSON objet that you send as the parameter "element"
  2. Vtiger Session ID not sent/correct in the parameter "sessionName"

See here an example (in PHP) of how to pass the object to perform an update

Upvotes: 0

Related Questions