0
我正在尝试将使用http
gem的终端中的curl请求转换为ruby代码。无法使用http ruby创建api请求gem
这是卷曲的要求,让我回了有效的JSON我想:
curl -X GET --header 'Accept: application/json' --header 'api_key: somekey' --header 'authtoken: sometoken' 'https://cdn.domain.io/v3/content_types/shirts/entries?environment=dev'
随着http gem我尝试做这在我的Ruby脚本:
HTTP.headers(:Accept => "application/json", :api_key => 'somekey', :authtoken => 'sometoken').get("https://cdn.domain.io/v3/content_types/shirts/entries", :params => { :environment => 'dev'}).body.readpartial
这给我的返回"api_key":["is not valid."]}
服务器出错
我在做什么错?我如何得到这个工作?
可能做出不同的'.header(...)'调用(连锁他们)像'.headers(接受: “应用/ JSON”)。头(api_key:'somekey')....'?我不知道http宝石;如果这个apporach工作,可能值得在github上签署一个bug报告。 – Felix
像你说的那样尝试链接。没有工作 –
没有得到与WEBrick v1.3.1,http v2.1.0和Rails v4.2.5的错误。也许发布有关如何重现的更多信息? –