0

Using DevDefined.OAuth I'm trying to update existing listing on Etsy. Here is my code:

_consumerContext = new OAuthConsumerContext
        {
            ConsumerKey = _apiKey,
            ConsumerSecret = _apiSecret,
            SignatureMethod = SignatureMethod.HmacSha1
        };

_session = new OAuthSession(_consumerContext, "https://openapi.etsy.com/v2/oauth/request_token?scope=transactions_r%20email_r%20listings_r%20transactions_w%20listings_w",
            "https://www.etsy.com/oauth/signin",
            "https://openapi.etsy.com/v2/oauth/access_token");

            _accessToken = new TokenBase();
            _accessToken.ConsumerKey = _apiKey;
            _accessToken.Token = token;
            _accessToken.TokenSecret = tokenSecret;

            IConsumerRequest request = _session.Request(_accessToken)
                .Put()
                .ForUri(new Uri(string.Format("https://openapi.etsy.com/v2/listings/{0}", listing_id)));

            request.Context.QueryParameters.Add("listing_id", listing_id.ToString());
            request.Context.QueryParameters.Add("title", "New title");

            string response = ConsumerRequestExtensions.ReadBody(request);

But I receive 403 response all the time with message "signature_invalid".

When I create listing on Etsy using the same way (except method is POST, not PUT), everything works fine.

Am I missing something?

Eugene Rozhkov
  • 663
  • 6
  • 10

2 Answers2

1

It depends what you mean by Update... Much simplified response below, to create the initial listing on Etsy call:

...
request.Resource = "/listing"
request.Method = Method.POST;
...

Then, to update a listing including stock and price, you must ensure that you have the listing's offering id and product identifier from Etsy, and ensure that this is set in the request data.

To get the product_identifier and offering id, make a GET call:

...
request.Resource = "/listings/my-etsy-listing-id/inventory"
request.Method = Method.GET;
...

To make further changes for eg Stock or Price, make the following call:

...
request.Resource = "/listings/my-etsy-listing-id/inventory"     
request.Method = Method.PUT;
...

To update title/description... call

...
request.Resource = "/listing/my-etsy-listing_id"
request.Method = Method.PUT;
...

As I said at the beginning, this is very much simplified. There is an awful lot of data that you need to send to do stuff in Etsy.

err1
  • 499
  • 9
  • 22
0

You can use the ETSY API method updateInventory to get your product listings updated on ETSY

$oauth = new OAuth(API KEYSTRING, API SHARED STRING);                        
$oauth->setToken($oauth_token, $oauth_token_secret);
$data = $oauth->fetch(
"https://openapi.etsy.com/v2/listings/$listing_id/inventory", [
'products' => $product_data
  'sku_on_property'      => ''
 ],
 OAUTH_HTTP_METHOD_PUT
 );

You can pass the product data as JSON in the $product_data fields to get your products updated on ETSY

CedCommerce
  • 1
  • 4
  • 11