繁体   English   中英

# <RestClient::NotFound: 404 Not Found> 错误+其余客户宝石

[英]#<RestClient::NotFound: 404 Not Found> error + rest-client gem

我在上传文件时遇到了其他客户端gem的以下错误。 宝石已正确安装。

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

其余客户端的参数是

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>

我正在使用邮递员客户打电话给我的休息终点。 对于每个请求,即时通讯都会收到相同的错误。

(byebug) e
#<RestClient::NotFound: 404 Not Found>

我尝试了其他rest client gem调用来调用端点。 对于我遇到的所有错误。

谢谢阿吉斯

我不得不将有效载荷转换为json并解决了问题。

RestClient::Request.execute(method: :put, url: url,
                            payload: payload.to_json, headers: headers)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM