faraday-cookie_jarthat implemented cookies forwarding between faraday requests as a middleware.
http-cookieto do that, you can see how that works in the middleware
You mentioned Postman, which I'd assume is the application running on your computer, but when you say that you get "execution expired" with Faraday, where is this Ruby code running?
Hi Matt, thanks for your response, it appears that docker network was the problem, I did a docker system prune and also I changed the way that I was creating the http client to block format and now It is working flawlessly
Hi, How do I use faraday to run requests parallelly when there is dependency among requests? For example, consider the below scenario:
Main Dep1 Dep2
1 -> 1.1 -> 1.2
3 -> 3.1 -> 3.2
4 -> 4.1
You can read the above as the app wanting to make a total of 9 requests with requests under Dep1 and Dep2 depending on the response from the main request. So, request 1.2 depends on request 1.1 which in turn depends on main request 1.
Faraday::Responseoffers a method called
on_complete, you can use that to chain dependent requests. Sorry about that lack of documentation around this but parallel requests is not a strength for any of the remaining maintainers, so we struggle a bit to provide support on this topic. We hope to revamp and improve this in the next major version though :thumbsup:
curlexample would definitely help, because I'm not sure the JSON standard allows for a "null" body, just an empty one I believe. But if you're able to make it work with
curlwe most probably can make it work on Faraday !
@scriptmonkey that looks to me like a simple string body with the word "null" is that it?
In that case, I believe you should be able to set that as your request body and manually set the
Faraday.post("https://api.dropboxapi.com/2/users/get_current_account", 'null', "Content-Type" => "application/json", "Authorization" => "Bearer mysupersecrettoken")
Here is another example taking full advantage of Faraday tools and middleware, including those provided by the
require 'faraday' require 'faraday_middleware' base_url = 'https://api.dropboxapi.com/2' conn = Faraday.new(base_url) do |f| f.request :authorization, :Bearer, 'mysupersecrettoken' f.request :json end conn.post('users/get_current_account', 'null')
Please do let me know if this works!
conn) for all subsequent calls to the same API and it will automatically make the body as JSON (even if you provide a Ruby structure like a hash or array) and set your bearer token on all requests