Date
1 - 4 of 4
right format for POST to login API?
Timothy Fong <timfong888@...>
Is this the right way to use rest-client in terms of passing in a method and the parameters to that method? Below is my code, and below is the documentation for the API: def restlogin require "rest-client" require 'digest/md5' username = 'whoami' password = Digest::MD5.hexdigest('mysekret') url = "http://sugarcrm.typhoon.apigee.com" restdata = {:user_name => username, :password => password} puts restdata.to_json client = RestClient.post(url, { :rest_data => restdata.to_json, :method => 'login', :input_type => 'json', :response_type => 'json' }) **** DOCUMENTATION **** * Log the user into the application * * @param UserAuth array $user_auth -- Set user_name and password (password needs to be * in the right encoding for the type of authentication the user is setup for. For Base * sugar validation, password is the MD5 sum of the plain text password. * @param String $application -- The name of the application you are logging in from. (Currently unused). * @param array $name_value_list -- Array of name value pair of extra parameters. As of today only 'language' and 'notifyonsave' is supported * @return Array - id - String id is the session_id of the session that was created. * - module_name - String - module name of user * - name_value_list - Array - The name value pair of user_id, user_name, user_language, user_currency_id, user_currency_name * @exception 'SoapFault' -- The SOAP error, if any */ Method [ public method login ] { - Parameters [3] { Parameter #0 [ $user_auth ] Parameter #1 [ $application ] Parameter #2 [ $name_value_list ] } } /** |
|
Archiloque <code@...>
Le 31 juil. 2010 à 23:57, Timothy Fong a écrit :
It seems ok, any issue or did you want to be sure before trying ? Notice that you can enable some logging on RestClient to be sure of what is being send to the server. Regards A. |
|
Timothy Fong <timfong888@...>
I get a response.code of 200...but according to the documentation, I am
assumed to receive a session id in the response, but don't see it...how
do most people parse the .json responses to assign to a variable?
toggle quoted message
Show quoted text
Archiloque wrote:
|
|
code@...
I get a response.code of 200...but according to the documentation, I amyou should be able to do parsed_response = JSON.parse(RestClient.post ....) |
|