SugarCRM 5.5.2 API REST - errore di accesso
Domanda
ho bisogno di essere in grado di utilizzare le API per SugarCRM per scambiare informazioni con diverse altre applicazioni. Ho trovato la documentazione API, e alcuni buoni articoli con il codice di esempio. Il risultato finale del mio codice è quello di inviare questo comando:
http: // localhost / SugarCRM / servizio / 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}
che produce questo errore { "Name": "Invalid Login", "numero": 10, "description": "Login tentativo è fallito si prega di controllare il nome utente e la password"} nullo
Googled l'errore e ha trovato molti altri con questo problema, ma nessuna soluzione.
Soluzione
Per quanto mi riguarda, avevo bisogno di usare qualcosa sulla falsariga di:
method = login & input_type = JSON e JSON response_type = & rest_data = $ REST_DATA
I dati REST è:
{
user_auth => {
user_name => $USERNAME,
password => $PW,
version => "1.2"
},
application => "foo"
}
(URL codificato)
Altri suggerimenti
Credo che la stringa REST corretta sarebbe come:
method = login & input_type = json & response_type = json & rest_data = { "user_auth": { "user_name": "utente", "password": "somemd5hash", "versione": "1.0"}, "application_name": "RestTest"}
(dovrebbe essere con codifica URL poi, naturalmente)
URL: http://mycrmurl.com/service/v4/rest.php
Richiesta dati - nel metodo POST
method = login & input_type = JSON & response_type = JSON & rest_data = { "user_auth": { "user_name": "username", "password": "md5password", "versione": "1.0"}, "application_name": "RestTest"}
Risposta da WS:
{ "id": "QualcheID", "module_name": "Utenti", "name_value_list": { "user_id": { "name": "user_id", "valore": "1"}, "nome_utente" : { "name": "nome_utente", "valore": "username"}, "USER_LANGUAGE": { "name": "USER_LANGUAGE", "valore": "en_us"}, "user_currency_id": { "nome": "user_currency_id", "valore": "- 99"}, "user_is_admin": { "name": "user_is_admin", "valore": true}, "user_default_team_id": { "name": "user_default_team_id", "valore" : null}, "user_default_dateformat": { "name": "user_default_dateformat", "valore": "m / d / Y"}, "user_default_timeformat": { "name": "user_default_timeformat", "valore": "h: ia "}," user_number_seperator ": {" name ":" user_number_seperator " "valore":", "}," user_decimal_seperator ": {" name ":" user_decimal_seperator " "valore":". "}," mobile_max_list_entries ": {" name ":" mobile_max_list_entries", "valore": null}, "mobile_max_subpanel_entries": { "name": "mobile_max_subpanel_entries", "valore": null}, "user_currency_name": { "name": "user_currency_name" , "valore": "dollaro"}}}