1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Why do I keep getting the error of "Item 'Feed' cannot be parsed" when trying to...

Discussão em 'Python' iniciado por Stack, Setembro 13, 2024.

  1. Stack

    Stack Membro Participativo

    I am using the sp-api python extension to import a test product through the JSON_LISTINGS_FEED and everything goes through into amazon ok, but once the feed is processed and I download the amazon document it says "Item 'Feed' cannot be parsed".

    I cannot figure out what is wrong as I am almost 100% positive everything I have is formatted correctly and i have compared my product json to the amazon json schema and everything is correct. Please let me know if there is any way you could help

    here is my python code:

    import requests
    import json, xml
    import simplejson
    import time
    import os
    from bs4 import BeautifulSoup
    from datetime import datetime, timedelta
    from io import BytesIO
    import sys
    import xml.etree.ElementTree as ET
    from sp_api.base import Marketplaces
    from sp_api.api import Orders
    from sp_api.api import Feeds


    url = "https://api.amazon.com/auth/o2/token"
    r = requests.post(url, data = {"grant_type": "refresh_token", "refresh_token": xxxxx)
    print(r.status_code)

    atoken = r.json()['access_token']
    rtoken = r.json()['refresh_token']

    credentials = dict(
    refresh_token = rtoken,
    lwa_app_id='xxxxx',
    lwa_client_secret='xxxxx',
    )

    feed = BytesIO()
    file = str.encode("amazonjson.json")
    feed.write(file)
    feed.seek(0)

    print(feed)
    response = Feeds(credentials = credentials, marketplace = Marketplaces.US).submit_feed("JSON_LISTINGS_FEED", file = feed, content_type="application/json; charset=utf-8")
    print(response)


    here is my json format:

    {
    "header": {
    "sellerId": "XXXXXXXXXXX",
    "version": "2.0",
    "issueLocale": "en_US"
    },
    "messages": [
    {
    "messageId": 1,
    "sku": "284.050.01",
    "operationType": "UPDATE",
    "productType": "LUGGAGE",
    "requirements": "LISTING",
    "attributes": {
    "item_name": [
    {
    "value": "TEST Title",
    "language_tag": "en_US",
    "marketplace_id": "ATVPDKIKX0DER"
    }
    ],
    "fulfillment_availability": [
    {
    "fulfillment_channel_code": "AMAZON_NA",
    "quantity": 10
    }
    ],
    "purchasable_offer": [
    {
    "currency": "US",
    "our_price": [
    {
    "schedule": [
    {
    "value_with_tax": 285.93
    }
    ]
    }
    ],
    "marketplace_id": "ATVPDKIKX0DER"
    }
    ]
    }
    }
    ]


    }

    Continue reading...

Compartilhe esta Página