[Vtigercrm-developers] REST

Nicolas Larcipretti niclarcipretti at gmail.com
Mon Jan 16 09:42:55 PST 2012


Here's the JSON i've used to do it, hope it helps:

{"potentialname":"someName","potential_no":"O40812","amount":"1000.00","related_to":"3x21363","closingdate":"2008-03-20","opportunity_type":"","nextstep":"","leadsource":"Outra","sales_stage":"Encerrada
e
Desqualificada","assigned_user_id":"20x719","probability":"50.000","campaignid":"","createdtime":"2008-03-14
00:00:00","modifiedtime":"2008-03-14
00:00:00","cd_territorio":"32x84000","cd_territorio_parceiro":"","cf_675":"0%","cf_676":"some","cf_683":"N\u00e3o
Possui","cf_689":"123","cf_696":"","cf_697":"","cf_698":"some
text","cf_699":"","cf_700":"","cf_701":"","cf_702":"","cf_703":"","cf_704":"","cf_705":"","cf_706":"","cf_707":"","cf_708":"","cf_709":"","cf_710":"","cf_711":"","cf_712":"Ganhador","cf_713":"Ganhador","cf_714":"0.00","cf_715":"0.00","cf_716":"Desconhecido","cf_717":"Desconhecido","cf_718":"","cf_719":"","cf_722":"0","cf_723":"0","cf_724":"0","cf_725":"0","cf_726":"0","cf_727":"","cf_728":"","cf_729":"","cf_730":"","cf_731":"5","cf_732":"","cf_733":"0","cf_763":"","cf_764":"","cf_765":"0","cf_766":"0","cf_767":"0","cf_768":"0","cf_769":"0","cf_770":"0","cf_771":"0","cf_772":"100","cf_773":"50","cf_774":"50","id":"5x115877"}'

Cheers

Nicolas
2012/1/16 Nicolas Larcipretti <niclarcipretti at gmail.com>

> Bobo,
>
> I've tested it here with accounts and potentials and both worked fine
> setting a group as the record's owner (used the admin user to do it). But
> now I think I know what's wrong with your call. Try to add an "id"
> attribute to your json with the same value as the "potential_id", that's
> the only thing missing.
>
> I'm using the 5.2.1 too.
>
> Cheers
>
> Nicolas
>
> 2012/1/16 Bobo Wieland <bobo at prisjakt.nu>
>
>>  I havn't had any problems with create/update using a non-admin user in
>> any other respect. But I tried to change my user to be admin, and also to
>> put the user in the group that Iäm trying to assign the potential to.
>>
>> I still get the same error message. Does anyone else have this problem?
>> Anyone that can verify it?
>>
>> btw, using vtiger 5.2.1...
>>
>>
>> Nicolas Larcipretti skrev 2012-01-13 13:15:
>>
>> When you create you session, do you use an admin user? Cause, AFAIK,
>> they're the only ones that can perform changes on any record. If you're
>> using any other user that doesn't have admin privileges, this will trigger
>> the "access denied" error.
>>
>>  Cheers
>>
>>  Nicolas
>>
>> 2012/1/13 Bobo Wieland <bobo at prisjakt.nu>
>>
>>>  I'm 100% sure that the session is correct. I havn't posted the whole
>>> chain of events here, but this is what I've done:
>>>
>>> 1. Verified my credentials and got a correct session.
>>> 2. Fetched a potential that I know to be assigned to a group (20x1756).
>>> 3a. Tried to change something in the potential and the update it without
>>> changing assigned_to. This causes the error.
>>> 3b. Create a new potential/edit another potential and set assigned_to to
>>> 20x1756. This causes the error (assigning the potential to a user (19xXXXX)
>>> works).
>>>
>>> This is all through the REST api using curl.
>>>
>>> Nicolas Larcipretti skrev 2012-01-13 12:58:
>>>
>>> Well, I've never used curl to do this before, but I think it can be used
>>> without problems.
>>>
>>>  Your request seems fine to me, the only things you need to check are:
>>> - the "sessionName", cause if you create the token in the wrong way, it
>>> won't let you finish the request.
>>> - the related id's that you're sending.
>>>
>>>  Are you shure that your group id is 1756? I don't know how many users
>>> you have, but usualy that a pretty high number to a group.
>>>
>>>  Can you show us how are you creating your session?
>>>
>>>  Cheers.
>>>
>>>  Nicolas
>>>
>>> 2012/1/13 Bobo Wieland <bobo at prisjakt.nu>
>>>
>>>>  Sure.
>>>>
>>>> Data array:
>>>>
>>>> [amount] => 0.00
>>>>     [referenceid] =>
>>>>     [special_price] => 0
>>>>     [email] =>
>>>>     [countrybusiness] => SE
>>>>     [price_type] => Pricegroup A
>>>>     [expected_close_date] => 2012-01-09
>>>>     [created_time] => 2012-01-09 10:53:48
>>>>     [description] => 120109/SalesBot - Självprofilering
>>>> 2012-01-09/SalesBot new status.
>>>>
>>>>     [modified_time] => 2012-01-13 10:25:50
>>>>     [next_step] =>
>>>>     [potential_name] => Featured Store - demo
>>>>     [type] => Featured Store
>>>>     [potential_no] => POT3232
>>>>     [probability_(%)] => 0.00
>>>>     [related_to] => 3x793
>>>>     [sales_stage] => Closed Won
>>>>     [assigned_to] => 20x1756
>>>>     [potentialid] => 5x53741
>>>>
>>>>
>>>>
>>>> This is the raw curl command:
>>>>
>>>> /usr/bin/curl --header 'Expect:' --header 'Authorization: Basic <CODE>'
>>>> --include --url '<VTIGER_URL>/webservice.php' --data
>>>> 'element=%7B%22amount%22%3A%220.00%22%2C%22cf_507%22%3A%22%22%2C%22cf_629%22%3A%220%22%2C%22cf_630%22%3A%22%22%2C%22cf_703%22%3A%22SE%22%2C%22cf_705%22%3A%22Pricegroup+A%22%2C%22closingdate%22%3A%222012-01-09%22%2C%22createdtime%22%3A%222012-01-09+10%3A53%3A48%22%2C%22description%22%3A%22120109%5C%2FSalesBot+-+Sj%5Cu00e4lvprofilering%5Cn2012-01-09%5C%2FSalesBot+new+status.%5Cn%22%2C%22modifiedtime%22%3A%222012-01-13+10%3A25%3A50%22%2C%22nextstep%22%3A%22%22%2C%22potentialname%22%3A%22Featured+Store+-+demo%22%2C%22opportunity_type%22%3A%22Featured+Store%22%2C%22potential_no%22%3A%22POT3232%22%2C%22probability%22%3A%220.00%22%2C%22related_to%22%3A%223x793%22%2C%22sales_stage%22%3A%22Closed+Won%22%2C%22assigned_user_id%22%3A%2220x1756%22%2C%22id%22%3A%225x53741%22%7D&operation=update&sessionName=672515d54f100e7a0cc2e'
>>>>
>>>>
>>>> Nicolas Larcipretti skrev 2012-01-13 11:36:
>>>>
>>>>  Can you paste here your entire REST call? I might help you cause I
>>>> have a method that does group creation via webservice here.
>>>>
>>>>  Cheers
>>>>
>>>>  Nicolas
>>>>
>>>> 2012/1/13 Bobo Wieland <bobo at prisjakt.nu>
>>>>
>>>>>  Coming back to this issue. Just ignored it for a while.
>>>>>
>>>>> Trying to set assigned_to for a potential to "20x1756" (which is a
>>>>> valid group that many potentials is assigned to in our vtiger system) still
>>>>> gives me the error message:
>>>>>
>>>>> "Cannot assign record to the given user (ACCESS_DENIED)"
>>>>>
>>>>> I do this using the REST Web Services using "update"
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> praneeth K skrev 2011-10-28 12:51:
>>>>>
>>>>> Hi ,
>>>>>
>>>>>
>>>>>   Generally group id will be in the format of '20x*groupId*'. I hope
>>>>> you are passing id to the REST api in the same format.
>>>>>
>>>>> On Fri, Oct 28, 2011 at 1:51 PM, Bobo Wieland <bobo at prisjakt.nu>wrote:
>>>>>
>>>>>> Using the REST-api, is it possible to set "assigned_to" for a
>>>>>> Potential
>>>>>> to a Group? I get an ACCESS_DENIED when I try even though it works
>>>>>> perfectly to set it to a group using the standard webinterface.
>>>>>>
>>>>>> best regards
>>>>>> Bobo Wieland - bobo at prisjakt.nu
>>>>>> _______________________________________________
>>>>>> iger.com/
>>>>>
>>>>>
>>
>> --
>> *Med vänliga hälsningar
>> Bobo - bobo at prisjakt.nu*
>>
>> _______________________________________________
>> http://www.vtiger.com/
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20120116/f562ddde/attachment-0002.html 


More information about the vtigercrm-developers mailing list