I got an issue following the basic steps for using the API with a private app.
Below is a piece of my code
def __get_session_for_shop(self): shop_url = u'https://%s:%s@%s.myshopify.com/admin' % (self.config.api_key, self.config.password, self.config.store_name) shopify.ShopifyResource.set_site(shop_url) return shopify.Shop.current() # Create product def create_product(self, product): # If we got permission to create a product if self.__valid_request(): print("We can create a product") if ('gtin' in product and shopify.Product.exists(product['gtin'])) or ('GTIN' in product and shopify.Product.exists(product['GTIN'])): pass else: shop = self.__get_session_for_shop() new_product = shopify.Product() new_product.title = "Name of the product" #new_product.handle = "The URL slug of the product" #new_product.product_type = "Category of the product" #new_product.body_html = "Description of the product" #new_product.vendor = "The Manufacturer of the product" #new_product.metafields_global_title_tag = "The meta title" #new_product.metafields_global_description_tag = "The description meta" #new_product.options = self.__get_options(product) #new_product.variants = self.__get_variants(product, new_product.options) saved_successfully = new_product.save() if not saved_successfully: print("Failed at creating")
When i try to save the product i get an issue where it can't parse the port correctly on the url (that little documentation there is, says nothing about a port being specified?)
InvalidURL at /api/v1/products/
nonnumeric port: 'PASSWORD@vuuh-com.myshopify.com'
If i add a :80 to the shop url then i just get another error:
UnicodeError at /api/v1/products/
encoding with 'idna' codec failed (UnicodeError: label empty or too long)
What am i doing wrong ??
The error happens at new_product.save()
It sounds like you may be experiencing the issue highlighted in this issue. Can you give this a read over, especially the section at the bottom highlighting a workaround, and let me know if you continue to experience this issue?
Ended up working on a public app instead. So code is fully redone for that.
The workaround works though
I'm not really sure about this but I've tried it with the id and it worked, just calling it for some reason made the save return true.
from the docs(https://github.com/Shopify/shopify_python_api😞
product = shopify.Product() product.title = "Shopify Logo T-Shirt" product.id # => 292082188312 product.save() # => True shopify.Product.exists(product.id) # => True product = shopify.Product.find(292082188312) # Resource holding our newly created Product object # Inspect attributes with product.attributes product.price = 19.99 product.save() # => True
Connect your PayPal account to allow your customers to checkout using the PayPal gateway a...By Ollie Jul 28, 2022