Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Etsy API question #30

Open
Allen209 opened this issue Sep 16, 2017 · 2 comments
Open

Etsy API question #30

Allen209 opened this issue Sep 16, 2017 · 2 comments

Comments

@Allen209
Copy link

Sorry to ask here but my question is probably really simple for you guys.

I am trying to use the updateListing method to revise listing descriptions...

https://www.etsy.com/developers/documentation/reference/listing#method_updatelisting

I went through the OAuth Authentication process successfully and am able to make an authorized request via the API as per the example in the documentation. I am having problems with the updateListing method. I am trying to revise the description but get the following error…

“Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect)Expected param 'quantity'.Array”

As per the documentation, the quantity is not required (and is actually depreciated for updateListing). When I use the existing quantity to populate ‘quantity’ in the array (commented out), it complains about another field it expects. I’m not sure why I’m getting an error regarding these fields as they are not required. I would not mind using the existing attributes available from my listing to populate these fields but there is a “shipping_template_id” field which I don’t currently have available. I can’t set it to null because it expects a numeric value. When I set it to 0, it says that it’s not a valid shipping template ID. I must be doing something wrong.

Here is my code (I replaced my actual token and token secrets)…

$access_token = "my token";
$access_token_secret = "my secret";

$oauth = new OAuth(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI);

$oauth->setToken($access_token, $access_token_secret);

try {

$url = "https://openapi.etsy.com/v2/private/listings";

$params = array('listing_id' => $result->listing_id,
                                 //'quantity' => $result->quantity,
                                //'title' => $result->title,
                                'description' => $new_description);

$oauth->fetch($url, $params, OAUTH_HTTP_METHOD_POST);
$json = $oauth->getLastResponse();
print_r(json_decode($json, true));

}
catch (OAuthException $e) {

echo $e->getMessage();
echo $oauth->getLastResponse();
echo $oauth->getLastResponseInfo();

}

@Amanej
Copy link

Amanej commented Sep 18, 2017

"I would not mind using the existing attributes available from my listing to populate these fields but there is a “shipping_template_id” field which I don’t currently have available."

You execute the "find_shipping_templates": https://www.etsy.com/developers/documentation/reference/shippingtemplate#method_findallshippingtemplateentries

The user you run the call against must have a shipping template, or you have to create with that method call.

That will get you the shipping_templates_id to update a listing.

@datenfalke
Copy link

You can get the available shipping profiles showing the needed id by using:

print_r($this->api->findAllUserShippingProfiles(array('params' => array('user_id' => 'SELF'))));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants