Ruby on rails #<;RestClient::NotFound:404未找到>;错误+;rest客户端gem

Ruby on rails #<;RestClient::NotFound:404未找到>;错误+;rest客户端gem,ruby-on-rails,ruby,rubygems,Ruby On Rails,Ruby,Rubygems,我在上传文件时遇到以下rest客户端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(meth

我在上传文件时遇到以下rest客户端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
rest客户端的参数为

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>
头是{“Authorization”=>“ApiKey SHctT2tSNE94Ijp0cnVlfQ.4ylskujurtqqqfincm2vrroyywjjxwi0wflsably74”,“content_type”=>“json”}
url为“https://sandbox.test-simplexcc.com/v2/users/604776/kyc"
有效负载是#,“控制器”=>“单工”、“操作”=>“更新”}允许的:真>
我在用邮递员客户呼叫我的休息终点。对于每个请求,我都会得到相同的错误

(byebug) e
#<RestClient::NotFound: 404 Not Found>
(byebug)e
#
我尝试了其他rest客户端gem调用来调用端点。无论做什么,我都会犯同样的错误

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

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

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

您确定@base_uri和url_path()设置正确吗?路径是否将接受put请求?404错误通常有一个非常具体的含义…您能在发送请求之前显示数据吗?(方法、url和负载)@MarcTalbot是。所有数据都很好,它需要一个put请求。我也尝试过其他一些get请求。同样的错误。这是一个文件上载操作。@a您应该编辑您的问题并将这些信息放在那里,而不是放在评论中(更容易阅读等)