lundi 27 avril 2015

Unable to send data from rails app in aws to android app

I have built a rails app which interacts with an android application. Sending and receiving data from android in local system is working flawlessly. But when I uploaded to AWS ec2, only I'm able to send data from android to server not the other way around. Please help me, struck with this.

I have used passenger gem to upload in aws.

My rails code to accept request from app which gives 200 OK

class Android::OnetimeloginController < ApplicationController
  respond_to :json
# This handles one time login from the android app

  def create

    # Takes up the credentials from the android app and
    # sends the header token to be used for further pings
        credentials = permitted_credentials

    # Checks the credentials and renders the responses 
      if credentials.has_key?("name")
        if Branch.exists?(name: credentials["name"]) && credentials["password"] == "password"

          response_json =  {"response" => "Yes"}
            render :json => response_json
        else
          render :text => "NO"
        end

      end

  end

  private

  def permitted_credentials
    params.require("credentials").permit(:name, :password, :tablet_id)
  end
end

But I'm not getting anything on the android side(although I get response in localhost)

I even got response for my CURL request. My curl command.

 curl -v -H "Content-type: application/json" -X POST -d ' {"credentials":{"name" : "banglore", "password": "password"}}'  http://IP/path_to_controller

I checked putting "Content-type" and "Accept" headers from android request, but no use. Please tell me where am I going wrong? Is it an AWS problem?

Thanks so much




Aucun commentaire:

Enregistrer un commentaire