前提・実現したいこと
cisco MerakiのScanning APIを使いPOSTされたjson形式のデータをRailsで取得したいです。
しかし、そのjsonを取得できません
rails側でエラーは出てないのですが、Merakiダッシュボードの方でエラーが表示されてます。
当方初心者なためそもそもrailsでjsonの取得のコーディングがあってるか怪しいです。
発生している問題・エラーメッセージ
Merakiダッシュボードで表示されてるエラー内容
”Did not match validator: http://wex01.cloud24.jp/personal_logs”
ruby
1#app/controllers/personal_logs_controller.rb 2validator ='xxxxxxxxxxxxxxxx' 3secret = 'xxxxxxxxxx' 4 5class PersonalLogsController < ApplicationController 6 skip_before_action :verify_authenticity_token 7 before_action :set_personal_log, only: [:show, :edit, :update, :destroy] 8 9 def presenceapi 10 if request.post? 11 map = JSON.parse(params[:data]).with_indifferent_access 12 if map[:secret] == secret 13 map[:probing].each do |p| 14 PersonalLog.create(ap_mac: p[:ap_mac], client_mac: p[:client_mac], 15 last_seen: DateTime.parse(p[:last_seen]), 16 rssi: p[:rssi]) 17 end 18 render :text => '' and return 19 else 20 Rails::logger.warn("*** MERAKI req with bad secret '#{map[:secret]}'") 21 rails 'access denied' 22 end 23 else 24 render :text => MERAKI_VALIDATOR 25 end 26 end 27end
ruby
1#config/routes.rb 2Rails.application.routes.draw do 3 match 'personal_logs', :to => 'personal_logs#presenceapi', :as => :personal_logs, :via => [:get, :post] 4end
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/07/26 01:02
2018/07/26 01:03
2018/07/26 01:10
2018/07/26 01:35
2018/07/26 01:51
2018/07/26 01:58
2018/07/26 02:11
2018/07/26 07:49