首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >#<RestClient::NotFound: 404 Not Found> error + rest-client gem

#<RestClient::NotFound: 404 Not Found> error + rest-client gem
EN

Stack Overflow用户
提问于 2018-06-28 16:01:07
回答 1查看 4.6K关注 0票数 0

在上传文件时,我得到了rest-client gem的以下错误。Gem已正确安装。

代码语言:javascript
复制
require 'rest-client'
class SimpleService
include RestClient

// other methods //

def update_request method, opts ={}
        headers = set_request_header
        payload = opts
        url = @base_uri + url_path(method)

        begin
            # RestClient.put url, payload, headers
            RestClient::Request.execute(method: :put, url: url,
                            payload: payload, headers: headers)
        rescue RestClient::ExceptionWithResponse => e
            byebug
            e.response
        end                    
    end
end

rest客户端的参数为

代码语言:javascript
复制
headers is {"Authorization"=>"ApiKey SHctT2tSNE94Ijp0cnVlfQ.4ylSKUJurtqCqfiNcm2vRROyHyWjJxWi0WFLsABLY74", "content_type"=>"json"} 

    url is "https://sandbox.test-simplexcc.com/v2/users/604776/kyc"

payload is <ActionController::Parameters {"identity_kyc_docunt_1"=>#<ActionDispatch::Http::UploadedFile:0x007fe2183a6d10 @tempfile=#<Tempfile:/var/folders/95/z56d5kd10_sb7s82b982fpjw0000gn/T/RackMultipart20180628-1288-1oncnou.png>, @original_filename="35155-6-adventure-time-picture.png", @content_type="image/png", @headers="Content-Disposition: form-data; name=\"identity_kyc_docunt_1\"; filename=\"35155-6-adventure-time-picture.png\"\r\nContent-Type: image/png\r\n">, "controller"=>"simplex", "action"=>"update_kyc"} permitted: true>

我正在使用邮递员客户端调用我的rest端点。对于每个请求,我都会得到相同的错误。

代码语言:javascript
复制
(byebug) e
#<RestClient::NotFound: 404 Not Found>

我尝试了其他rest客户端gem调用来调用端点。对于每件事,我都得到了相同的错误。

谢谢,阿吉斯

EN

回答 1

Stack Overflow用户

发布于 2018-06-29 14:22:52

我必须将有效负载转换为json,它解决了这个问题。

代码语言:javascript
复制
RestClient::Request.execute(method: :put, url: url,
                            payload: payload.to_json, headers: headers)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51077684

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档