403 Forbidden while creating a Coupon

794 views
Skip to first unread message

SnakeO

unread,
Dec 8, 2011, 10:47:50 PM12/8/11
to Etsy API V2
I'm creating a Coupon. I have these permissions:

email_r
transactions_r
shops_rw

Here's a dump of the URL call:
GET /v2/shops/6440761/coupons?
limit=100&method=POST&coupon_code=couponcodetest&pct_discount=35.5&free_shipping=true&oauth_consumer_key=emt8n1w5dda7qdq7vwypzlqe&oauth_signature_method=HMAC-
SHA1&oauth_nonce=15368668144ee183851cc4d5.64468046&oauth_timestamp=1323402117&oauth_version=1.0&oauth_token=22340ce1509d9c53878af969598341&oauth_signature=bKn65q
%2FDRAlfHg7mj29b9bfCEZ0%3D

User-Agent: PECL-OAuth/1.2.2
Host: openapi.etsy.com
Accept: */*

(this is a test shop that I use , it's not in a sandbox).

Coupon API says all I need is the shops_rw permission, but I get this
back:

Date: Fri, 09 Dec 2011 03:41:57 GMT
Server: Apache
X-Error-Detail: This method not accessible to restricted API key.
X-Etsy-Request-Uuid: bMa0263xgD7XtSQ02UqP0KLO54UL
Content-Length: 49
X-Cnection: close
Content-Type: text/plain;charset=UTF-8

This method not accessible to restricted API key.


Loving the Etsy API. Help Please

Zach

unread,
Dec 8, 2011, 10:54:53 PM12/8/11
to etsy-...@googlegroups.com
You need to use a POST request with the variables as POST variables (http://www.etsy.com/developers/documentation/reference/coupon - The HTTP method for  create_coupon is POST.)


Additionally, here are some things you need to be aware about when creating a coupon 

- coupon_code has to be all capitalized and only alphabets and numeric characters seem to be allowed. 

- pct_discount needs to be an integer value (i think). 

Hope this helps!


Zach 


--
You received this message because you are subscribed to the Google Groups "Etsy API V2" group.
To post to this group, send email to etsy-...@googlegroups.com.
To unsubscribe from this group, send email to etsy-api-v2...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/etsy-api-v2?hl=en.


SnakeO

unread,
Dec 8, 2011, 11:03:22 PM12/8/11
to Etsy API V2
Thanks for the quick reply Zach! I tried again with POST:

POST /v2/shops/6440761/coupons?
limit=100&method=POST&api_key=emt8n1w5dda7qdq7vwypzlqe&coupon_code=TESTCOUPON&pct_discount=35&free_shipping=true&oauth_consumer_key=emt8n1w5dda7qdq7vwypzlqe&oauth_signature_method=HMAC-
SHA1&oauth_nonce=17851789844ee187efe7b063.58259997&oauth_timestamp=1323403247&oauth_version=1.0&oauth_token=22340ce1509d9c53878af969598341&oauth_signature=MVugsrpz0GBAwkyXh3HQe12ipyY
%3D HTTP/1.1


User-Agent: PECL-OAuth/1.2.2
Host: openapi.etsy.com
Accept: */*

With this response:

HTTP/1.1 403 Forbidden
Date: Fri, 09 Dec 2011 04:00:48 GMT


Server: Apache
X-Error-Detail: This method not accessible to restricted API key.

X-Etsy-Request-Uuid: CC0EJ2TLsPfmnjh-j-IRiwn37oZE


Content-Length: 49
X-Cnection: close
Content-Type: text/plain;charset=UTF-8

This method not accessible to restricted API key.

I made sure that my oauth_token was valid by re-issuing it, so I
definitely have shops_rw permissions. I'm so sad, I'm on a roll and I
got stuck on this for a while now.

On Dec 8, 9:54 pm, Zach <zach.ch...@gmail.com> wrote:
> You need to use a POST request with the variables as POST variables (http://www.etsy.com/developers/documentation/reference/coupon- The HTTP

SnakeO

unread,
Dec 8, 2011, 11:16:19 PM12/8/11
to Etsy API V2
Under what circumstances would that error pop up? If it's ONLY in the
case that I don't have the correct permissions, then is there a
permission I'm missing?

Zach

unread,
Dec 8, 2011, 11:16:56 PM12/8/11
to etsy-...@googlegroups.com
Not too sure whether this matters, but your url looks like you are passing the variables in the url as get variables. You may need to pass it to etsy through post variables where the data is passed within the body of the http request, rather than through the url. (http://stackoverflow.com/questions/504947/when-should-i-use-get-or-post-method-whats-the-difference-between-them)



Zach 

SnakeO

unread,
Dec 8, 2011, 11:32:25 PM12/8/11
to Etsy API V2
Zach, you're absolutely right! I modified my code, and the data that
should be POSTed is now being passed via POST:


POST /v2/shops/6440761/coupons?
oauth_consumer_key=emt8n1w5dda7qdq7vwypzlqe&oauth_signature_method=HMAC-
SHA1&oauth_nonce=11546032604ee18ee26a8d73.84577032&oauth_timestamp=1323405026&oauth_version=1.0&oauth_token=22340ce1509d9c53878af969598341&oauth_signature=4%2B0MVLVdOEGRFVFEjUqOxQkHU9A


%3D HTTP/1.1
User-Agent: PECL-OAuth/1.2.2
Host: openapi.etsy.com
Accept: */*

Content-Length: 57
Content-Type: application/x-www-form-urlencoded

coupon_code=TESTCOUPON&pct_discount=35&free_shipping=true

And here's the result:

TTP/1.1 403 Forbidden
Date: Fri, 09 Dec 2011 04:30:26 GMT


Server: Apache
X-Error-Detail: This method not accessible to restricted API key.

X-Etsy-Request-Uuid: d24Apgc_4COa1ODIA2W4MuAhH24I


Content-Length: 49
X-Cnection: close
Content-Type: text/plain;charset=UTF-8

This method not accessible to restricted API key.


The same thing! :( I'm so frustrated right now...

SnakeO

unread,
Dec 8, 2011, 11:51:35 PM12/8/11
to Etsy API V2
Update: I tried with ALL permissions, and I'm still getting the same
error. I'm utterly confused, I think I'm doing everything right!

david olick

unread,
Dec 9, 2011, 7:51:52 AM12/9/11
to etsy-...@googlegroups.com
A POST does not look like that.  It looks like this:

POST http://openapi.etsy.com/v2/private/listings/12345/images?oauth_consumer_key=[key]&oauth_nonce=[stuff]&oauth_signature=[sig]&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1323386166&oauth_token=[token]&oauth_version=1.0
Content-Length: 201
Content-Type: multipart/form-data; boundary=xYzZY

--xYzZY
Content-Disposition: form-data; name="image"; filename="filename.jpg"
Content-Type: image/jpeg

[an image]
--xYzZY
Content-Disposition: form-data; name="rank"

2
--xYzZY--





This post has 2 parameters: image and rank.  Image has a value of "[an image]" and rank has a value of 2.  It would be the equivalent of "?image=[image]&rank=2".

A lot of people think that you can just toss the data from the url to the body and expect it to work, however it just doesn't work like that.  You need to declare a separater, which in my case is xYzZY, and a couple other things.  You should try using a library if possible.  Otherwise, you'll likely have to look up the details on how it's done.

By the way, what's above is in the format of "multipart/form-data".

- David


On Thu, Dec 8, 2011 at 10:51 PM, SnakeO <jake...@gmail.com> wrote:
Update: I tried with ALL permissions, and I'm still getting the same
error. I'm utterly confused, I think I'm doing everything right!
--
You received this message because you are subscribed to the Google Groups "Etsy API V2" group.
To post to this group, send email to etsy-...@googlegroups.com.
To unsubscribe from this group, send email to etsy-api-v2...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/etsy-api-v2?hl=en.




--
David Olick
CTO
Oriku Inc.

GraGra33

unread,
Dec 9, 2011, 8:47:27 AM12/9/11
to Etsy API V2
Actually, both are correct.

The issue with the error SnakeO is experiencing is that he is using a
Sandbox only "Restricted" write/post keyset on the live environment -
error "This method not accessible to restricted API key". If SnakeO
points to the sandbox, it should work.

G.

On Dec 9, 11:51 pm, david olick <da...@fotofuze.com> wrote:
> A POST does not look like that.  It looks like this:
>

> POSThttp://openapi.etsy.com/v2/private/listings/12345/images?oauth_consum...[key]&oauth_nonce=[stuff]&oauth_signature=[sig]&oauth_signature_method=HMAC­-SHA1&oauth_timestamp=1323386166&oauth_token=[token]&oauth_version=1.0


> Content-Length: 201
> Content-Type: multipart/form-data; boundary=xYzZY
>
> --xYzZY
> Content-Disposition: form-data; name="image"; filename="filename.jpg"
> Content-Type: image/jpeg
>
> [an image]
> --xYzZY
> Content-Disposition: form-data; name="rank"
>
> 2
> --xYzZY--
>
> This post has 2 parameters: image and rank.  Image has a value of "[an
> image]" and rank has a value of 2.  It would be the equivalent of
> "?image=[image]&rank=2".
>
> A lot of people think that you can just toss the data from the url to the
> body and expect it to work, however it just doesn't work like that.  You
> need to declare a separater, which in my case is xYzZY, and a couple other
> things.  You should try using a library if possible.  Otherwise, you'll
> likely have to look up the details on how it's done.
>
> By the way, what's above is in the format of "multipart/form-data".
>
> - David
>

SnakeO

unread,
Dec 9, 2011, 3:36:51 PM12/9/11
to Etsy API V2
Thanks GraGra, You're right. I need to "Get Full Access" on my API
key. Thanks you

On Dec 9, 7:47 am, GraGra33 <gragr...@gmail.com> wrote:
> Actually, both are correct.
>
> The issue with the error SnakeO is experiencing is that he is using a
> Sandbox only "Restricted" write/post  keyset on the live environment -
> error "This method not accessible to restricted API key". If SnakeO
> points to the sandbox, it should work.
>
> G.
>
> On Dec 9, 11:51 pm, david olick <da...@fotofuze.com> wrote:
>
>
>
>
>
>
>
> > A POST does not look like that.  It looks like this:
>

> > POSThttp://openapi.etsy.com/v2/private/listings/12345/images?oauth_consum...[key]&oauth_nonce=[stuff]&oauth_signature=[sig]&oauth_signature_method=H MAC­-SHA1&oauth_timestamp=1323386166&oauth_token=[token]&oauth_version=1.0

Justin Kerr Sheckler

unread,
Dec 9, 2011, 7:29:19 PM12/9/11
to etsy-...@googlegroups.com
Hi there,

Your API was not yet approved for full API access.  I've fixed that, so you should be able to use those methods now.

best,

Justin Kerr Sheckler
Developer API Lead
Etsy.com
jus...@etsy.com



On Thu, Dec 8, 2011 at 10:47 PM, SnakeO <jake...@gmail.com> wrote:
emt8n1w5dda7qdq7vwypzlqe

Reply all
Reply to author
Forward
0 new messages