【问题标题】:Updating widget via curl通过 curl 更新小部件
【发布时间】:2014-04-03 23:05:32
【问题描述】:

我是 dashing 的新手,按照here 的说明进行操作,成功启动并运行了“sweet_dashboard_project”。

仪表板底部显示:

"Try this: curl -d '{ "auth_token": "YOUR_AUTH_TOKEN", "text": "Hey, Look what I can do!" }' \http://localhost:3030/widgets/welcome"

当我尝试时,出现以下错误:

    curl: (6) Could not resolve host: auth_token
    curl: (6) Could not resolve host: YOUR_AUTH_TOKEN,
    curl: (6) Could not resolve host: text
    curl: (6) Could not resolve host: Hey, Look what I can do!
    curl: (3) [globbing] unmatched close brace/bracket in column 1
    curl: (1) Protocol \http not supported or disabled in libcurl

config.ru 看起来像这样

require 'dashing'

configure do
  set :auth_token, 'YOUR_AUTH_TOKEN'

  helpers do
    def protected!
     # Put any authentication code you want in here.
     # This method is run before accessing any resource.
    end
  end
end

map Sinatra::Application.assets_prefix do
  run Sinatra::Application.sprockets
end

run Sinatra::Application

我在这里做错了什么?

谢谢!

【问题讨论】:

  • 您的引用命令有问题,请在此处粘贴您的真实命令!

标签: ruby curl dashing


【解决方案1】:

您使用的 \http 不正确。

另外,在 json 周围加上双引号(如果你使用 windows)。使用标题application/json

curl -d "{ \"auth_token\": \"YOUR_AUTH_TOKEN\", \"text\": \"Hey, Look what I can do!\" }' -H "Content-Type: application/json" http://localhost:3030/widgets/welcome

【讨论】:

  • 我在尝试这个时遇到错误,curl: (6) 无法解析主机:应用程序
  • 将括号后的单引号更改为双引号对我有用。谢谢
【解决方案2】:

假设您使用的是 Windows,这将起作用吗?

curl -X POST  -H "Content-Type: application/json" -d "{ \"auth_token\": \"YOUR_AUTH_TOKEN\", \"text\": \"Hey, Look what I can do!\" }" http://localhost:3030/widgets/welcome

【讨论】:

    猜你喜欢
    • 2014-05-28
    • 2016-01-15
    • 1970-01-01
    • 1970-01-01
    • 2011-06-15
    • 1970-01-01
    • 1970-01-01
    • 2013-12-17
    • 2013-10-04
    相关资源
    最近更新 更多