http = HTTPClient.new
jpeg_path = "#{Rails.root}/#{[path]}"
uri = URI.parse(url)
File.open(jpeg_path) do |jpeg|
headers = {"Authorization" => "Bearer #{auth_info['access_token']}"}
body = { 'original' => jpeg, 'slug' => 'woohoo' }
response = http.post(uri, body, headers)
####
my $browser = LWP::UserAgent->new;
$browser->timeout(30);
my $response = $browser->request(
POST $upload_url,
Content_Type => 'form-data',
Headers => { Authorization => 'Bearer ' . $json_auth->{access_token} },
Content => [
'slug' => 'woohoo',
Filedata => [$image],
]
);
####
HTTP/1.1 400 Bad Request
Cache-Control: no-store, no-transform
Date: Thu, 28 Nov 2013 14:28:57 GMT
Server: Jetty(7.4.5.v20110725)
WWW-Authenticate: Bearer
Content-Type: application/json
Client-Date: Thu, 28 Nov 2013 14:28:57 GMT
Client-Peer: xxx.xxx.xxx.xxx:xxx
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /C=US/O=GeoTrust, Inc./CN=RapidSSL CA
Client-SSL-Cert-Subject: /serialNumber=mUOvwBDD0H95debkB/h5KKaWmke7/2cy/OU=GT28122842/OU=See www.rapidssl.com/resources/cps (c)12/OU=Domain Control Validated - RapidSSL(R)/CN=*.private.dev.xxxxx.com
Client-SSL-Cipher: RC4-MD5
Client-SSL-Warning: Peer certificate not verified
Client-Transfer-Encoding: chunked
Set-Cookie: NSC_dnt-tfswjdf-iuuq=ffffffffc3a0d98c45525d5f4f58455e445a4a4229a0;expires=Thu, 28-Nov-2013 14:31:03 GMT;path=/;secure;httponly
X-NYTD-CMS-Host: cms-service01.qprvt.xxxxxx.com
{
"error": "invalid_request",
"error_description": "This service requires authentication"
}