open-api icon indicating copy to clipboard operation
open-api copied to clipboard

[BUG]: "error":"Server Error" returned on PUT request for updateListing

Open Allen209 opened this issue 2 years ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

I am re-writing the V2 api code for the new V3. I am trying to update the quantity of a listing. I did a token exchange from my legacy token (which has write access as I am currently able to update listings). The token exchange was successful but when I try and call the updateListing endpoint, I get "error":"Server Error"

Steps to reproduce

Here is my sample code as per step #4 in https://developer.etsy.com/documentation/tutorials/listings/#listing-a-digital-product-for-sale

<?php

$url = 'https://openapi.etsy.com/v3/application/shops/' . $shop_id . '/listings/' . $result->listing_id;

$body = array(
    'quantity' => $quantity
  );
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
  curl_setopt($ch, CURLOPT_HEADER, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($body));
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/x-www-form-urlencoded; charset=utf-8',
        'x-api-key: ' . $api_key,
        'authorization: Bearer ' . $token
    ));  
    
   $response = curl_exec($ch);
   var_dump($response);

I get "error":"Server Error" as a response. It is validating my token because it tells me when it's expired. I also tried this with wp_remote_post() and get the same error message. I am able to make other calls to the V3 API but not a PUT/updateListing. Can you please let me know why I'm getting this error? Was anyone successful with a PUT/updateListing API call?

I also found the same issue here: https://githubhot.com/repo/etsy/open-api/issues/191?page=2 This was posted by a former Etsy employee who wrote this and is trying to update to V3: https://github.com/mcfunley/etsy-python

Expected behavior

I expect to update the listing quantity.

Additional context

No response

Allen209 avatar Apr 18 '22 16:04 Allen209