Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect); Image file or image_id string must be included

664 views
Skip to first unread message

Marty Sainty

unread,
Dec 8, 2013, 7:44:20 AM12/8/13
to etsy-...@googlegroups.com
Hi,

I keep receiving the above error when updating an existing listing with a new image. Ive tested and got this working on my local machine but now I'm testing on the domain I keep getting that error. 'Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect); Image file or image_id string must be included'

Here is the string being parsed in

$image['image'] = '/home/etsycsv/public_html/public/images/54/Best_Images.jpg';

$arr = array('@image'=>'$image['image'];type='.$image['mime']); //image/jpeg);
        self::makeRequest('/listings/'.$listing_id.'/images',$arr,'POST');

Can anyone help with this?

cheers,

Marty

Marty Sainty

unread,
Dec 8, 2013, 12:17:37 PM12/8/13
to etsy-...@googlegroups.com
This is the debug response

Array ( [sbs] => POST&https%3A%2F%2Fopenapi.etsy.com%2Fv2%2Flistings%theid%2Fimages&oauth_consumer_key%blaaaaaa2%26oauth_nonce%3Dmoooo%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1386522811%26oauth_token%3nononononono%26oauth_version%3D1.1 [headers_recv] => HTTP/1.1 400 Bad Request Date: Sun, 08 Dec 2013 17:13:31 GMT Server: Apache X-RateLimit-Limit: 10000 X-RateLimit-Remaining: 9922 X-Error-Detail: Image file or image_id string must be included X-Etsy-Request-Uuid: KMGcYKdG01kFwzoWQMzx_6Tvvw7n Cache-Control: private X-Cnection: close Content-Type: text/plain;charset=UTF-8 Content-Length: 46 Accept-Ranges: bytes Via: 1.1 varnish Age: 0 X-Served-By: cache-lcy1135-LCY X-Cache: MISS X-Cache-Hits: 0 X-Timer: S1386522811.536708593,VS0,VE121 Set-Cookie: uaid=uaid%3Dp3lCjkBVQYCe2R31OWziyNuqiBdQ%26_now%3D1386522811%26_slt%3D8nXJIOv0%26_kid%3D1%26_ver%3D1%26_mac%3Dwm-P2ECeHjBAB34S2LA8Yf2HfU2Jsr9uqAKav3DV_iw.; expires=Tue, 08-Dec-2015 17:13:31 GMT; path=/; domain=.etsy.com; httponly Connection: close [body_recv] => Image file or image_id string must be included )

david olick

unread,
Dec 8, 2013, 3:55:41 PM12/8/13
to Etsy API V2
Is it possible you could give us some raw packet info?  It's usually much easier for everyone to understand what's going on or what you're missing with packet information.  Just giving us code (in a language we probably aren't familiar with) helps us less than you might think it does.  (Also, you didn't even mention what language, oauth package, etc you are using)

Here's an example:

POST http://openapi.etsy.com/v2/private/listings/85635566/images?oauth_consumer_key=<removed>&oauth_nonce=<removed>&oauth_signature=<removed>&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1383593600&oauth_token=<removed>&oauth_version=1.0
Content-Length: 265
Content-Type: multipart/form-data; boundary=xYzZY

--xYzZY

Content-Disposition: form-data; name="image"; filename="fotofuze.jpg"

Content-Type: image/jpeg

[lots of random characters]

--xYzZY

Content-Disposition: form-data; name="rank"

1

--xYzZY

Content-Disposition: form-data; name="overwrite"

1

--xYzZY--


--
David Olick
Oriku Inc.


--
You received this message because you are subscribed to the Google Groups "Etsy API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to etsy-api-v2...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Matt Graham

unread,
Dec 9, 2013, 12:01:55 PM12/9/13
to Etsy API Mailing List
Hi Marty,

Instead of:
$arr = array('@image'=>'$image['image'];type='.$image['mime']); //image/jpeg);
        self::makeRequest('/listings/'.$listing_id.'/images',$arr,'POST');

I think maybe you want:
$arr = array('image'=>"@{$image['image']};type=".$image['mime']);

        self::makeRequest('/listings/'.$listing_id.'/images',$arr,'POST');

Also, make sure that the image filename is an absolute path.

Good luck,
Matt




--

Marty Sainty

unread,
Dec 12, 2013, 1:30:33 PM12/12/13
to etsy-...@googlegroups.com
Hey Matt, David

Cheers for the reply,

I have actually found what the issue is,

For anyone having the same problem it is to do with the request engine. You need to add $oauth->setRequestEngine( OAUTH_REQENGINE_CURL );

However, as I have come find there can also be issues with the request engne curl not being added during the installation of PHP Oauth. If you echo out phpInfo(); and look for Oauth you'll see the available request engines.

If you do not see curl as an optional engine then you haven't got it

Here is a link I found on how to fix it,

http://www.davidogilo.co.uk/technical/how-to-fix-oauth_reqengine_curl-is-undefined/

I cant confirm it works yet as I'm currently waiting for my server guys to sort it out. I can confirm that the problem is with the request engne as I have tested it on localhost by changing the request engine to $oauth->setRequestEngine( OAUTH_REQENGINE_STREAMS ); and I receive the exact same error. When I change the request engine to curl the upload works fine.

I'll confirm once I they have got around to it.

cheers,

Marty


On Sunday, 8 December 2013 12:44:20 UTC, Marty Sainty wrote:
Reply all
Reply to author
Forward
0 new messages