ruby - "HTTP 302 Moved Temporarily" when CURL on Cloud9 using Rails -


i have simple app take requests create events. should take request using url , check registeredapplication, if it's found, should create event linked registeredapplication.

the problem that, seems it's not working on cloud9! response i've got when doing curl command:

* hostname not found in dns cache *   trying 104.154.33.155... * connected blocmetrics-klaha1.c9.io (104.154.33.155) port 443 (#0) * set certificate verify locations: *   cafile: none   capath: /etc/ssl/certs * sslv3, tls handshake, client hello (1): * sslv3, tls handshake, server hello (2): * sslv3, tls handshake, cert (11): * sslv3, tls handshake, server key exchange (12): * sslv3, tls handshake, server finished (14): * sslv3, tls handshake, client key exchange (16): * sslv3, tls change cipher, client hello (1): * sslv3, tls handshake, finished (20): * sslv3, tls change cipher, client hello (1): * sslv3, tls handshake, finished (20): * ssl connection using ecdhe-rsa-aes256-sha384 * server certificate: *        subject: ou=domain control validated; ou=essentialssl wildcard; cn=*.c9.io *        start date: 2015-03-17 00:00:00 gmt *        expire date: 2016-05-03 23:59:59 gmt *        subjectaltname: blocmetrics-klaha1.c9.io matched *        issuer: c=gb; st=greater manchester; l=salford; o=comodo ca limited; cn=comodo rsa domain validation secure server ca *        ssl certificate verify ok. > post /api/events http/1.1 > user-agent: curl/7.35.0 > host: blocmetrics-klaha1.c9.io > accept: application/json > origin: keeblerheaney.net > content-type: application/json > content-length: 17 >  * upload sent off: 17 out of 17 bytes < http/1.1 302 moved temporarily < location: https://c9.io/api/nc/auth?response_type=token&client_id=proxy&redirect=http%3a%2f%2fblocmetrics-klaha1.c9.io%2fapi%2fevents < date: thu, 14 may 2015 21:15:55 gmt < transfer-encoding: chunked <  * connection #0 host blocmetrics-klaha1.c9.io left intact 

this routes.rb

namespace :api, defaults: { format: :json }   resources :events, only: [:create] end 

this api/events_controller.rb

class api::eventscontroller < applicationcontroller   skip_before_action :verify_authenticity_token    def create     registered_application = registeredapplication.find_by(url: request.env['http_origin'])      if registered_application.nil?       render json: "unregistered application", status: :unprocessable_entity     end      @event = registered_application.events.build(event_params)      if @event.save       render json: @event, status: :created     else       render @event.errors, status: :unprocessable_entity     end    end    private    def event_params     params.require(:event).permit(:name)   end  end 

a change did on config/initializers/inflections.rb

activesupport::inflector.inflections(:en) |inflect|   inflect.acronym 'api' end 

and finally, curl command i'm using.

curl -v -h "accept: application/json" -h "origin: keeblerheaney.net" -h "content-type: application/json" -x post -d '{"name":"foobar"}'  https://blocmetrics-klaha1.c9.io/api/events 

what doing wrong here? lending me hand!

is workspace public? not. if you'd keep code private, running server accessible everyone, can go click on 'share' within menu, , check 'public' next 'application', make running server public without exposing source.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -