I am trying to realize the curl contents below in ruby.
There are 400 errors and it doesn't work.
How should I describe the -F option of curl in ruby? April 18, 2018 Thank you for your comment. Below are the codes and errors. ■ Code ■Error Dear Kunif, Thank you for your comment. April 23, 2018 Thank you for your comment. curl-F grant_type=refresh_token-Frefresh_token=<refresh token>client_id=<client id>-F client_secret=<client secret>-X POST https://test/token
Sorry for the inconvenience, but I look forward to hearing from you.
Dear cubick and nekketsuuuuu
I'm sorry, but I didn't list any code or errors that I tried to implement.
Your question was not good.def updateAccessToken()
json='"
uri=URI.parse("http://test/token")
Net::HTTP.start(uri.host,uri.port){|http|
request=Net::HTTP::Post.new(uri.path)
request.set_form_data('grant_type'=>'refresh_token')
request.set_form_data('refresh_token'=>'dfafdasfdasdfadsfsa3')
request.set_form_data('client_id'=>'2121fdasgadsraea')
request.set_form_data('client_secret'=>'2121fdasgadsraea')
json=http.request(request)
}
return json
end
Net::HTTPBadRequest 400 Bad Request readbody=true
I also tried the website you introduced me to, but the error I mentioned above appeared, so
The result was the same.
Dear Kunif,
I would like to conduct a survey using the method of the link that you introduced.
Thank you for your repeated support.
400 Bad Request
is not what the server expects.
Curl's -F issues a Content-Type:multipart/form-data
request, but Ruby's Net::HTTP::Post
issues a Content-Type:application/x-www-form-urlocated
request.
If Ruby wants to issue a Content-Type: multipart/form-data
request, it is recommended to use set_form
instead of set_form_data
.
I think the next page will be helpful.
http://masamitsu-murase.blogspot.jp/2017/01/ruby-nethttp-multipart-post.html
© 2024 OneMinuteCode. All rights reserved.