Code Monkey home page Code Monkey logo

Comments (10)

pascale64 avatar pascale64 commented on July 30, 2024

Hi, I have research why I have the origional error, I Had used pip3 top install the package afte a system update but I had an old version, so now I have version 0.0.6, I am getting a new error, I believe this is still because I am not sending the UpdateListingRequest incorrectly, I am sending ihe list as a dictonary;
body={'image_ids':[],
'title': 'Vintage French table lamp in quality bronze with a handmade lampshade of your choice',
'description': 'A stunning vintage French table lamp for your home. brocante\n\n\nMerci de votre visite -Thanks for your visit!\n\nNUMERO TARIFAIRE69091900B\nPOIDS1.8KGBY23/10/11McoTRC',
'materials': ['Bronze', 'Fabric', 'Lampshade polyphane', 'Metal rings'],
'should_auto_renew': True,
'shipping_profile_id': 55880902836,
'shop_section_id': 20081659,
'item_weight': 0.0,
'item_length': 0.0,
'item_width': 0.0,
'item_height': 0.0,
'item_weight_unit': 'g',
'item_dimensions_unit': 'mm',
'is_taxable': True,
'taxonomy_id': 2815,
'tags': ['table lamp', 'handmade lampshade', 'country home', 'farmhouse decor', 'classic decor', 'rococo', 'living room', 'toile de Jouy', 'French toile', 'signed bronze', 'blue and gold', 'acanthus', 'chateau decor'],
'who_made': 'someone_else',
'when_made': '1930s',
'featured_rank': 0,
'is_personalizable': False,
'personalization_is_required': False,
'personalization_char_count_max': False,
'personalization_instructions': False,
'state': 'inactive',
'is_supply': False,
'production_partner_ids': [],
'listing_type': 'physical'}
to
bdf_update=BDF_Etsy.update_listing(985775823, 1585777523, body)
I am now getting
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.9/dist-packages/etsyv3/etsy_api.py", line 340, in update_listing
return self._issue_request(uri, method=Method.PATCH, request_payload=listing)
File "/usr/local/lib/python3.9/dist-packages/etsyv3/etsy_api.py", line 162, in _issue_request
raise Exception()
All help is greatly needed.
Warm regards
Paul

from etsyv3.

pascale64 avatar pascale64 commented on July 30, 2024

Hi, I have decided to test what comes out of the UpdateListingRequest(Request), so I found that no ater how I tried to nut the data, List, Dict, String etc all of the items where grouped together as part of the first item "image_id" as follows
body={"image_ids":[],
"title": "Vintage French table lamp in quality bronze with a handmade lampshade of your choice",
"description": "A stunning vintage French table lamp for your home. brocante\n\n\nMerci de votre visite -Thanks for your visit!\n\nNUMERO TARIFAIRE69091900B\nPOIDS1.8KGBY23/10/11McoTRC",
"materials": ["Bronze", "Fabric", "Lampshade polyphane", "Metal rings"],
"should_auto_renew": True,
"shipping_profile_id": 55880902836,
"shop_section_id": 20081659,
"item_weight": "",
"item_length": "",
"item_width": "",
"item_height": "",
"item_weight_unit": "g",
"item_dimensions_unit": "mm",
"is_taxable": True,
"taxonomy_id": 2815,
"tags": ["table lamp", "handmade lampshade", "country home", "farmhouse decor", "classic decor", "rococo", "living room", "toile de Jouy", "French toile", "signed bronze", "blue and gold", "acanthus", "chateau decor"],
"who_made": "someone_else",
"when_made": "1930s",
"featured_rank": 0,
"is_personalizable": False,
"personalization_char_count_max": False,
"personalization_instructions": False,
"state": "active",
"is_supply": False,
"production_partner_ids": [],
"listing_type": "physical"}
returned ;

"personalization_is_required": False,'{"image_ids": {"image_ids": [], "title": "Vintage French table lamp in quality bronze with a handmade lampshade of your choice", "description": "A stunning vintage French table lamp for your home. brocante\n\n\nMerci de votre visite -Thanks for your visit!\n\nNUMERO TARIFAIRE69091900B\nPOIDS1.8KGBY23/10/11McoTRC", "materials": ["Bronze", "Fabric", "Lampshade polyphane", "Metal rings"], "should_auto_renew": true, "shipping_profile_id": 55880902836, "shop_section_id": 20081659, "item_weight": "", "item_length": "", "item_width": "", "item_height": "", "item_weight_unit": "g", "item_dimensions_unit": "mm", "is_taxable": true, "taxonomy_id": 2815, "tags": ["table lamp", "handmade lampshade", "country home", "farmhouse decor", "classic decor", "rococo", "living room", "toile de Jouy", "French toile", "signed bronze", "blue and gold", "acanthus", "chateau decor"], "who_made": "someone_else", "when_made": "1930s", "featured_rank": 0, "is_personalizable": false, "personalization_is_required": false, "personalization_char_count_max": false, "personalization_instructions": false, "state": "active", "is_supply": false, "production_partner_ids": [], "listing_type": "physical"}, "title": null, "description": null, "materials": null, "should_auto_renew": null, "shipping_profile_id": null, "shop_section_id": null, "item_weight": null, "item_length": null, "item_width": null, "item_height": null, "item_weight_unit": null, "item_dimensions_unit": null, "is_taxable": null, "taxonomy_id": null, "tags": null, "who_made": null, "when_made": null, "featured_rank": null, "is_personalizable": null, "personalization_is_required": null, "personalization_char_count_max": null, "personalization_instructions": null, "state": null, "is_supply": null, "production_partner_ids": null, "listing_type": null, "_nullable": ["materials", "shipping_profile_id", "shop_section_id", "item_weight", "item_length", "item_width", "item_height", "item_weight_unit", "item_dimensions_unit", "tags", "featured_rank", "production_partner_ids", "type"], "_mandatory": []}'
so I tried the simpliest
body = [], "hello"

body = ([], "hello")
r = UpdateListingRequest(body)
r= json.dumps(r.dict)
r
'{"image_ids": [[], "hello"], "title": null, "description": null, "materials": null, "should_auto_renew": null, "shipping_profile_id": null, "shop_section_id": null, "item_weight": null, "item_length": null, "item_width": null, "item_height": null, "item_weight_unit": null, "item_dimensions_unit": null, "is_taxable": null, "taxonomy_id": null, "tags": null, "who_made": null, "when_made": null, "featured_rank": null, "is_personalizable": null, "personalization_is_required": null, "personalization_char_count_max": null, "personalization_instructions": null, "state": null, "is_supply": null, "production_partner_ids": null, "listing_type": null, "_nullable": ["materials", "shipping_profile_id", "shop_section_id", "item_weight", "item_length", "item_width", "item_height", "item_weight_unit", "item_dimensions_unit", "tags", "featured_rank", "production_partner_ids", "type"], "_mandatory": []}'

I am at a complete loss
Please Help!
Warm regards
Paul

from etsyv3.

anitabyte avatar anitabyte commented on July 30, 2024

Hi Paul,

You shouldn't be able to create an UpdateListingRequest like that - it should raise an exception. I'll double check that - I might have removed the code that handled that by accident.

If you try to create the UpdateListingRequest like this (eg):

r = UpdateListingRequest(title="New title", description="Description")

or

body = {title: "New Title", description: "Description"}
r = UpdateListingRequest(**body)

You might have better luck.

from etsyv3.

pascale64 avatar pascale64 commented on July 30, 2024

Hi Anitabyte
Thank you for getting back to me, what I really want to know is what do I pass to "update_listing", as the part "listing", I have tried dictionaries list and tuples, but I get the same error, I have tried ;
body={
"title": "Vintage French table lamp in quality bronze with a handmade lampshade of your choice",
}

bdf_update=BDF_Etsy.update_listing(985775823, 1585777523, **body)
TypeError: update_listing() got an unexpected keyword argument 'title'
bdf_update=BDF_Etsy.update_listing(985775823, 1585777523,title="Vintage French table lamp in quality bronze with a handmade lampshade of your choice",listing_type= "physical")
but I get the same error.
TypeError: update_listing() got an unexpected keyword argument 'title'
I have read the
For POST and PUT requests (requests that need payloads), there are subclassed Request types for each type. They generally take all required arguments into a constructor that is then serialised into JSON when passed to an API-calling method. Where you wish to null an optional parameter in a call, you should create the request parameter with the empty-form of whatever you're trying to null, so if the API takes a string, provide ""; if a list, [].
but I dont understand how to construct this pay load.
This is a project for me, I sell on Ebay and Etsy, so when an item sells on one site I can deactivate it on the other, I could just delete the listing, but this will not help me understand how to construct a payload.
my code for finances and sales works great as I dont need to pass a payload
Thank you for your help and code
Warm regards
Paul

from etsyv3.

d-winch avatar d-winch commented on July 30, 2024

Hi Anitabyte Thank you for getting back to me, what I really want to know is what do I pass to "update_listing", as the part "listing", I have tried dictionaries list and tuples, but I get the same error, I have tried ; body={ "title": "Vintage French table lamp in quality bronze with a handmade lampshade of your choice", }

bdf_update=BDF_Etsy.update_listing(985775823, 1585777523, **body) TypeError: update_listing() got an unexpected keyword argument 'title' bdf_update=BDF_Etsy.update_listing(985775823, 1585777523,title="Vintage French table lamp in quality bronze with a handmade lampshade of your choice",listing_type= "physical") but I get the same error. TypeError: update_listing() got an unexpected keyword argument 'title' I have read the For POST and PUT requests (requests that need payloads), there are subclassed Request types for each type. They generally take all required arguments into a constructor that is then serialised into JSON when passed to an API-calling method. Where you wish to null an optional parameter in a call, you should create the request parameter with the empty-form of whatever you're trying to null, so if the API takes a string, provide ""; if a list, []. but I dont understand how to construct this pay load. This is a project for me, I sell on Ebay and Etsy, so when an item sells on one site I can deactivate it on the other, I could just delete the listing, but this will not help me understand how to construct a payload. my code for finances and sales works great as I dont need to pass a payload Thank you for your help and code Warm regards Paul

You need to provide the update_listing method with a type of UpdateListingRequest, rather than dict, tuple, etc.

You can create one by first importing the UpdateListingRequest from etsyv3/models/listing_request.py and then passing your arguments.

E.g.,

req = UpdateListingRequest(
        title = "Test Title"
        description = "Test Description"
        materials = "Cotton"
        ...
        listing_type = ListingType.PHYSICAL
)

Then pass the UpdateListingRequest variable.
update_listing(shop_id=985775823, listing_id=1585777523, listing=req)

If you have your details in a body dict, as anitabyte showed, you should be able to unpack the dict as the input
req = UpdateListingRequest(**body)

Or even
update_listing(shop_id=985775823, listing_id=1585777523, listing=UpdateListingRequest(**body))

from etsyv3.

pascale64 avatar pascale64 commented on July 30, 2024

Hi David
Thank you so much for your help, I am making great progress and understanding more, I am now getting an error
File "/usr/local/lib/python3.9/dist-packages/etsyv3/etsy_api.py", line 340, in update_listing
return self._issue_request(uri, method=Method.PATCH, request_payload=listing)
File "/usr/local/lib/python3.9/dist-packages/etsyv3/etsy_api.py", line 164, in _issue_request
raise BadRequest(return_val.json())
etsyv3.etsy_api.BadRequest: {'error': 'Invalid value (null) for boolean'}

I am passing a reduced list as body, it includes all the items marked as booleans, this is what results from;
req = UpdateListingRequest(**body)
req.dict
{'image_ids': [], 'title': 'test ', 'description': 'A stunning ', 'materials': None, 'should_auto_renew': True, 'shipping_profile_id': None, 'shop_section_id': None, 'item_weight': None, 'item_length': None, 'item_width': None, 'item_height': None, 'item_weight_unit': None, 'item_dimensions_unit': None, 'is_taxable': True, 'taxonomy_id': 2815, 'tags': None, 'who_made': 'someone_else', 'when_made': '1930s', 'featured_rank': None, 'is_personalizable': False, 'personalization_is_required': False, 'personalization_char_count_max': 0, 'personalization_instructions': '', 'state': 'active', 'is_supply': False, 'production_partner_ids': None, 'listing_type': None, '_nullable': ['materials', 'shipping_profile_id', 'shop_section_id', 'item_weight', 'item_length', 'item_width', 'item_height', 'item_weight_unit', 'item_dimensions_unit', 'tags', 'featured_rank', 'production_partner_ids', 'type'], '_mandatory': []}
I am not sure where I am going wrong, Thanks for your help
Warm regards
Paul

from etsyv3.

d-winch avatar d-winch commented on July 30, 2024

@pascale64 Could you provide the full code including where you set the body variable?

You can put three backticks (`) before and after your code to format it nicely.

from etsyv3.

pascale64 avatar pascale64 commented on July 30, 2024

Thank you for getting back to me,here is my code
from etsyv3 import EtsyAPI
from etsyv3.models import Request, UpdateListingRequest
BDF_Etsy = EtsyAPI(
keystring = bdfapi.keystring,
token = bdfapi.access_token,
refresh_token = bdfapi.refresh_token,
expiry = bdfapi.expires_at
)

body={"image_ids":[],
"title": "test Vintage French table lamp in quality bronze with a handmade lampshade of your choice",
"description": "A stunning vintage French table lamp for your home. brocante\n\n\nMerci de votre visite -Thanks for your visit!\n\nNUMERO TARIFAIRE69091900B\nPOIDS1.8KGBY23/10/11McoTRC",
"should_auto_renew": True,
"is_taxable": True,
"taxonomy_id": 2815,
"who_made": "someone_else",
"when_made": "1930s",
"is_personalizable": False,
"personalization_is_required": False,
"personalization_char_count_max": 0,
"personalization_instructions": "",
"state": "active",
"is_supply": False,}

BDF_Etsy.update_listing(shop_id=985775823, listing_id=1585777523, listing=UpdateListingRequest(**body))
this is where I get the "boolean "erreur", so I then tried this;
reg = BDF_Etsy.UpdateListingRequest(**body)
reg.dict
and got this;
'image_ids': [], 'title': 'test ', 'description': 'A stunning ', 'materials': None, 'should_auto_renew': True, 'shipping_profile_id': None, 'shop_section_id': None, 'item_weight': None, 'item_length': None, 'item_width': None, 'item_height': None, 'item_weight_unit': None, 'item_dimensions_unit': None, 'is_taxable': True, 'taxonomy_id': 2815, 'tags': None, 'who_made': 'someone_else', 'when_made': '1930s', 'featured_rank': None, 'is_personalizable': False, 'personalization_is_required': False, 'personalization_char_count_max': 0, 'personalization_instructions': '', 'state': 'active', 'is_supply': False, 'production_partner_ids': None, 'listing_type': None, '_nullable': ['materials', 'shipping_profile_id', 'shop_section_id', 'item_weight', 'item_length', 'item_width', 'item_height', 'item_weight_unit', 'item_dimensions_unit', 'tags', 'featured_rank', 'production_partner_ids', 'type'], '_mandatory': []}
when I look at the class UpdateListingRequest in models I see that only the following are booleans;
should_auto_renew:, is_taxable:,is_personalizable:personalization_is_required:,is_supply:
which I have made True or False, I have left out the items that are nullable, I also tried 1 or 0 instead of
Hope this helps.
Warm regards
Paul

from etsyv3.

pascale64 avatar pascale64 commented on July 30, 2024

David and Anitabyte,
I have resolved the issue, all items in the body dict must be strings; ie a boolean must be "True" or "False", and integers
must be strings as well"12345", this why I was getting the boolean erreur message, and atleast one image_id must be sent aswell as image_ids:["123456"],
or you get an erreur aswell, I hope this helps anybody following me, as this is an excellent piece of code, now I can run Ebay and Etsy shops at the same time not having to worry about selling the same product over night whilst I sleep!
Many thanks again
Warm regards
Paul

from etsyv3.

d-winch avatar d-winch commented on July 30, 2024

I'm under the belief that the bools get converted to strings but don't have time to check at the moment. If passing a string works then that's great.

I would only pass the data you need to update. So if there are no image_ids to update, don't include it in your body.

from etsyv3.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.