Question

I need to be able to use the API for SugarCRM to exchange information with several other applications. I found the api docs, and some good articles with sample code. The end result of my code is to send this command:

http://localhost/sugarcrm/service/v2/rest.php?method=login&input_type=json&response_type=json&rest_data={%22user_name%22:%22rest%22,%22password%22:%2265e8800b5c6800aad896f888b2a62afc%22,%22version%22:%22.01%22}

Which produces this error {"name":"Invalid Login","number":10,"description":"Login attempt failed please check the username and password"}null

I have googled the error and found several others with this issue, but no solution.

Was it helpful?

Solution

For me, I needed to use something along the lines of:

method=login&input_type=JSON&response_type=JSON&rest_data=$REST_DATA

The REST data is:

{
  user_auth => {
    user_name => $USERNAME,
    password => $PW,
    version => "1.2"
  },
  application => "foo"
}

(URL encoded)

OTHER TIPS

I think the proper REST string would be like:

method=login&input_type=json&response_type=json&rest_data={"user_auth": {"user_name":"user","password":"somemd5hash","version":"1.0"},"application_name":"RestTest"}

(should be url-encoded then of course)

URL : http://mycrmurl.com/service/v4/rest.php

Request Data - in POST method

method=login&input_type=JSON&response_type=JSON&rest_data={"user_auth":{"user_name":"username","password":"md5password","version":"1.0"},"application_name":"RestTest"}

Response from WS:

{"id":"someID","module_name":"Users","name_value_list":{"user_id":{"name":"user_id","value":"1"},"user_name":{"name":"user_name","value":"username"},"user_language":{"name":"user_language","value":"en_us"},"user_currency_id":{"name":"user_currency_id","value":"-99"},"user_is_admin":{"name":"user_is_admin","value":true},"user_default_team_id":{"name":"user_default_team_id","value":null},"user_default_dateformat":{"name":"user_default_dateformat","value":"m/d/Y"},"user_default_timeformat":{"name":"user_default_timeformat","value":"h:ia"},"user_number_seperator":{"name":"user_number_seperator","value":","},"user_decimal_seperator":{"name":"user_decimal_seperator","value":"."},"mobile_max_list_entries":{"name":"mobile_max_list_entries","value":null},"mobile_max_subpanel_entries":{"name":"mobile_max_subpanel_entries","value":null},"user_currency_name":{"name":"user_currency_name","value":"US Dollars"}}}

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top