3 Replies Latest reply on Oct 8, 2013 4:51 AM by Kutir Mobility

    Migrating Rho::AsyncHttp.post/get to Rho::Network.post/get

      hi,

      I am migrating an application written in RhoMobile 2.2 to RhoMobile 4.

      the current application make a number of Http request using Rho::AsyncHttp.post to get/post data to web services as follows:

      Rho::AsyncHttp.post(
      :url => "https://www.somedomain.com/ServiceName",
      :headers => { "Content-Type" => "application/json; charset=utf-8" },
      :body => {"key" => "value"}.to_json,
      :ssl_verify_peer => false,
      :callback => url_for(:action => :request_callback),
      :callback_param => "callback_param_hash={'key1' => 'value1', 'key2' => 'value2'}"
      )
      
      

       

      based on the new Rho::Network api (Rhomobile | Network) i have converted the above into the following, however in the request_callback function the @param parameter hash do not contain the "callback_param_hash" key:

      propertyMap = Hash.new
      propertyMap['url'] = "https://www.somedomain.com/ServiceName"
      propertyMap['headers'] = { "Content-Type" => "application/json; charset=utf-8" }
      propertyMap['body'] = {"key" => "value"}.to_json
      propertyMap['verifyPeerCertificate'] = false
      propertyMap['callback_param'] = "callback_param_hash={'key1' => 'vale1', 'key2' => 'value2'}"
      Rho::Network.post(propertyMap, url_for(:action => :request_callback))
      
      

       

      is the callback_param property still supported; if so how can i set the value to the parameter?

      if no, what are the recommended alternatives to get the required values to the callback function?

       

      in another section of the application, currently an synchronous (without a callback) "AsyncHttp.get" request is being made as follows using basic authentication:

      result = Rho::AsyncHttp.get(
      :url => "https://www.somedomain.com/ServiceName2/DataID_123",
      :headers => { "Content-Type" => "application/json; charset=utf-8" },
      :ssl_verify_peer => false,
      :authentication => {
                  :type => :basic,
                  :username => "some_user_name",
                  :password => "some_password"
              }
      )
      

       

      how do i use the authentication bit for the new Rho::Network api? I have given the following a go, but its not working:

      propertyMap = Hash.new
      propertyMap['url'] = "https://www.somedomain.com/ServiceName2/DataID_123"
      propertyMap['headers'] = { "Content-Type" => "application/json; charset=utf-8" }
      propertyMap['verifyPeerCertificate'] = false
      propertyMap['authType'] = "basic"
      propertyMap['authUser'] = "some_user_name"
      propertyMap['authPassword'] = "some_password"
      result = Rho::Network.get(propertyMap)
      

       

       

      thanks.

       

      Message was edited by: Ameer Ilahi