Greetings, and Happy Holidays! I'm having a problem utilizing an API and its required fields with HTTP::Request::Common. The first request returns a token (this works), that is used by the second request to upload an image (my problem). I've tried numerous permutations but can't seem to nail it. There is no formal documentation for the api, so I've just been poking it with a pointy stick. The api requires the following: from a coworkers ruby program:
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)
This is what I have so far and the response
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/2c +y/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=ffffffffc3a0d98c45525d5f4f58455e445a4 +a4229a0;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" }
Any help would be greatly appreciated! Thanks in advance,
2013-11-28 Retitled by GrandFather, as per Monastery guidelines
In reply to Request to Upload an Image by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |