使用 Typhoeus 将数组 POST 到 URL

发布于 2024-12-22 03:52:19 字数 831 浏览 3 评论 0原文

我正在使用 Typhoeus 将哈希值发布到我的 API url。它实际上是一个包含一组哈希值的数组。这实际上是我正在做的事情:

companies = Array.new
company = { 'name' => 'Company 1' , 'company_url' => 'http://company.com' }
companies.push(company)
company2 = {'name' => 'Company 2' , 'company_url' => 'http://company2.com' }
companies.push(company2)

request = Typhoeus::Request.post("http://myapi.com/1.0/startups/create_batch",
                                 :username => 'user',
                                 :password => 'password',
                                 :auth_method => :basic,
                                 :params => {'companies' => companies} )
print "Create_batch response "+request.body

运行脚本后,我得到的输出显示“Create_batch 响应不允许的关键字符。”。我现在不确定它指的是什么。我查看了印刷公司显示的文本输出,但没有看到任何奇怪的代码。

有人对我应该做什么有任何见解吗?

I'm using Typhoeus to post a hash to my API url. It's actually an array containing a set of hashes. Here's effectively what I'm doing:

companies = Array.new
company = { 'name' => 'Company 1' , 'company_url' => 'http://company.com' }
companies.push(company)
company2 = {'name' => 'Company 2' , 'company_url' => 'http://company2.com' }
companies.push(company2)

request = Typhoeus::Request.post("http://myapi.com/1.0/startups/create_batch",
                                 :username => 'user',
                                 :password => 'password',
                                 :auth_method => :basic,
                                 :params => {'companies' => companies} )
print "Create_batch response "+request.body

Once I run the script I get the output which states "Create_batch response Disallowed Key Characters.". I'm not sure what it's referencing at this point. I've looked over the text output of what print companies shows up but I don't see any strange code.

Anybody have any insights on what I should do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文