httpclient
httpclient copied to clipboard
OPTIONS request should support an entity-body
It is valid to specify an entity-body when making an OPTIONS request. However, the current behavior of HTTPClient#options will take the contents of the specified :body argument and attempt to create header params. It also looks like HTTPClient#options_async would behave the same way.
This is an example of a working cURL command that should be possible:
curl https://api.box.com/2.0/files/content -H "Authorization: Bearer Fyu4FzznJVohJbVGQ37durvkOpRokKFR" -d '{"name":"test.txt", "parent":{"id":"0"},"size":"0"}' -X OPTIONS
Hi Hiroshi, I have a quick question about multipart post with a custom body. I am trying to post with one part being a JSON string and the second part being the binary file. I cannot get this to work even after looking at your example where your body is an array with two hashes.
3. Do multipart with custom body.
File.open('/tmp/post_data') do |file|
body = [{ 'Content-Type' => 'application/atom+xml; charset=UTF-8',
:content => '... ' },
{ 'Content-Type' => 'video/mp4',
'Content-Transfer-Encoding' => 'binary',
:content => file }]
res = clnt.post(uri, body)
end
Here is the snippet I’m trying that is not resulting in multipart with the two custom bodies:
json_attributes = "{'name':'chad.txt','parent':{'id':'#{parent_id}'}}"
attributes = [{'Content-Type' => 'application/json', :content => json_attributes}, {'Content-Type' => 'text/plain', :content => file}]
Any help on how to do this would be very much appreciated.
Chad
On Oct 18, 2014, at 11:24 AM, Hiroshi Nakamura [email protected] wrote:
Closed #215 https://github.com/nahi/httpclient/issues/215 via 6b891ed https://github.com/nahi/httpclient/commit/6b891edd9f48ebae60991cf6010518086a655126.
— Reply to this email directly or view it on GitHub https://github.com/nahi/httpclient/issues/215#event-180407366.
To be a little clearer, I’m trying to recreate this type of cURL command with your gem:
curl https://upload.box.com/api/2.0/files/content
-H "Authorization: Bearer ACCESS_TOKEN" -X POST
-F attributes='{"name":"tigers.jpeg", "parent":{"id":"11446498"}}'
-F [email protected]
On Mar 5, 2015, at 2:58 PM, Chad Burnette [email protected] wrote:
Hi Hiroshi, I have a quick question about multipart post with a custom body. I am trying to post with one part being a JSON string and the second part being the binary file. I cannot get this to work even after looking at your example where your body is an array with two hashes.
3. Do multipart with custom body.
File.open('/tmp/post_data') do |file|
body = [{ 'Content-Type' => 'application/atom+xml; charset=UTF-8',
:content => '
... ' },{ 'Content-Type' => 'video/mp4',
'Content-Transfer-Encoding' => 'binary',
:content => file }]
res = clnt.post(uri, body)
end
Here is the snippet I’m trying that is not resulting in multipart with the two custom bodies:
json_attributes = "{'name':'chad.txt','parent':{'id':'#{parent_id}'}}" attributes = [{'Content-Type' => 'application/json', :content => json_attributes}, {'Content-Type' => 'text/plain', :content => file}]
Any help on how to do this would be very much appreciated.
Chad
On Oct 18, 2014, at 11:24 AM, Hiroshi Nakamura <[email protected] mailto:[email protected]> wrote:
Closed #215 https://github.com/nahi/httpclient/issues/215 via 6b891ed https://github.com/nahi/httpclient/commit/6b891edd9f48ebae60991cf6010518086a655126.
— Reply to this email directly or view it on GitHub https://github.com/nahi/httpclient/issues/215#event-180407366.
Hiroshi, just curious if this is something you will have a fix for soon. If not I need to use a workaround in my gem until this gets fixed. thanks!
Hi, just checking in again on this issue.
hey there, checking in on this.
thanks, Chad