SugarCRM: Getting "Invalid Session ID" error with REST calls
I'm using SugarCRM CE 6.0.3.
When I make REST API calls like get_entry_list(), I always get this error:
{'description': 'The session ID is invalid',
'name':开发者_如何转开发 'Invalid Session ID',
'number': 11}
I am very sure that I am logged in and using the correct session ID. In fact, when I can successfully call get_user_id() and retrieve my own user ID.
Googling has not produced any helpful results, anyone else encountered this problem?
I have found the problem, it is really just a matter of bad documentation on SugarCRM's part. The parameter naming is all wrong in this document:
http://developers.sugarcrm.com/docs/OS/6.0/-docs-Developer_Guides-Sugar_Developer_Guide_6.0-Chapter%202%20Application%20Framework.html#9000259
Simple fix for this problem: Do not use named parameters when making REST calls in SugarCRM. i.e. Use positional parameters (JSON array) for 'rest_data' in API calls.
I encountered this issue with the set_entry api call. For me the issue is one of the values that I was submitting to the call contained special characters that the api couldn't handle. My solution was to urlencode
the value, and Sugar decodes it on their end. See below:
$name = "abc's ; 10/10/2013";
$values = array(
"name"=>$name
);
$sugar->set_entry("Accounts", $values);
The above threw the Invalid session ID
error. Below is the code that works:
$name = urlencode("abc's ; 10/10/2013");
$values = array(
"name"=>$name
);
$sugar->set_entry("Accounts", $values);
精彩评论