allegro / allegro-api

Issue tracker and wiki for Allegro REST API
https://developer.allegro.pl/
217 stars 39 forks source link

HttpMessageNotReadableException when uploading products #9869

Open marcusskelly opened 2 months ago

marcusskelly commented 2 months ago

I have been uploading products successfully via API but recently all I get is a HttpMessageNotReadableException. The trace_id of my las request is this: 80f220b3cc0b7313. I think all parameters are alright so cant really get my head around the issue I am having tbh.

Lukasz-Zurek commented 2 months ago

Your request has some additional, duplicated arrays and unnecessary values (I have marked them with "to remove" text, just for arrays and values):

{
    "name": "LG Home Cinema Projector",
    "category": {
        "id": "259431"
    },
    "images": [
        {
            "url": "https://a.allegroimg.allegrosandbox.pl/original/1137f5/b807819c40d1b32b1f39dbc7eddb"
        },
        {
            "url": "https://a.allegroimg.allegrosandbox.pl/original/11080a/97674eaa44208d6b61f00c6f68dc"
        },
        {
            "url": "https://a.allegroimg.allegrosandbox.pl/original/11a8db/7c60d781401e8710a3a69a558196"
        }
    ],
    "parameters": [
        {
            "id": "236422",
            "name": "Marka",
            "valuesIds": [ 
                [ - to remove
                    "236422_1641823",
                    "LG" - to remove
                ] - to remove
            ] 
        },
        {
            "id": "237206",
            "name": "Model",
            "values": [
                "LG573"
            ]
        },
        {
            "id": "204789",
            "name": "Kolor",
            "valuesIds": [ 
                [ - to remove
                    "204789_221705",
                    "biau0142y" - to remove
                ] - to remove
            ]
        },
        {
            "id": "204793",
            "name": "Technologia wyu015bwietlania",
            "valuesIds": [
                [ - to remove
                    "204793_221733",
                    "LCD" - to remove
                ] - to remove
            ]
        },
        {
            "id": "1445",
            "name": "Jasnou015bu0107 lampy (ANSI)",
            "values": [
                "3000 lm"
            ]
        },
        {
            "id": "204829",
            "name": "Rozdzielczou015bu0107 podstawowa (px)",
            "valuesIds": [
                [ - to remove
                    "204829_221801",
                    "1920 x 1080" - to remove
                ] - to remove
            ]
        },
        {
            "id": "225693",
            "name": "EAN (GTIN)",
            "values": [
                "8806092978423"
            ],
            "options": {
                "identifiesProduct": true,
                "isGTIN": true
            }
        },
        {
            "id": "224017",
            "name": "Kod producenta",
            "values": [
                "EPSONPROJ123"
            ]
        }
    ],
    "description": {
        "sections": [
            {
                "items": [
                    {
                        "type": "TEXT",
                        "content": "<p>Home Cinema Projector - Bring the cinema experience home.</p>"
                    }
                ]
            }
        ]
    },
    "language": "pl-PL"
}

So it should look like this:

{
    "name": "LG Home Cinema Projector",
    "category": {
        "id": "259431"
    },
    "images": [
        {
            "url": "https://a.allegroimg.allegrosandbox.pl/original/1137f5/b807819c40d1b32b1f39dbc7eddb"
        },
        {
            "url": "https://a.allegroimg.allegrosandbox.pl/original/11080a/97674eaa44208d6b61f00c6f68dc"
        },
        {
            "url": "https://a.allegroimg.allegrosandbox.pl/original/11a8db/7c60d781401e8710a3a69a558196"
        }
    ],
    "parameters": [
        {
            "id": "236422",
            "name": "Marka",
            "valuesIds":
                [
                    "236422_1641823"
                ]
        },
        {
            "id": "237206",
            "name": "Model",
            "values": [
                "LG573"
            ]
        },
        {
            "id": "204789",
            "name": "Kolor",
            "valuesIds":
                [
                    "204789_221705"
                ]
        },
        {
            "id": "204793",
            "name": "Technologia wyu015bwietlania",
            "valuesIds":
                [
                    "204793_221733"
                ]
        },
        {
            "id": "1445",
            "name": "Jasnou015bu0107 lampy (ANSI)",
            "values": [
                "3000 lm"
            ]
        },
        {
            "id": "204829",
            "name": "Rozdzielczou015bu0107 podstawowa (px)",
            "valuesIds":
                [
                    "204829_221801"
                ]
        },
        {
            "id": "225693",
            "name": "EAN (GTIN)",
            "values": [
                "8806092978423"
            ],
            "options": {
                "identifiesProduct": true,
                "isGTIN": true
            }
        },
        {
            "id": "224017",
            "name": "Kod producenta",
            "values": [
                "EPSONPROJ123"
            ]
        }
    ],
    "description": {
        "sections": [
            {
                "items": [
                    {
                        "type": "TEXT",
                        "content": "<p>Home Cinema Projector - Bring the cinema experience home.</p>"
                    }
                ]
            }
        ]
    },
    "language": "pl-PL"
}
marcusskelly commented 2 months ago

I have obtained the same structure I believe but still not working :(

{ "name": "LG Home Cinema Projector", "category": { "id": "259431" }, "images": [ {"url": "https://a.allegroimg.allegrosandbox.pl/original/113ad7/96ef30ac45c1b7233836cacd6f03"}, {"url": "https://a.allegroimg.allegrosandbox.pl/original/11ceb7/165e12304c5d9757a10329d203aa"}, {"url": "https://a.allegroimg.allegrosandbox.pl/original/11a47c/3cac98234bc6b1a0ec5e64566331"} ], "parameters": [ {"id": "236422", "name": "Marka", "valuesIds": ["236422_1641823"]}, {"id": "237206", "name": "Model", "values": ["LG573"]}, {"id": "204789", "name": "Kolor", "valuesIds": ["204789_221705"]}, {"id": "204793", "name": "Technologia wyświetlania", "valuesIds": ["204793_221733"]}, {"id": "1445", "name": "Jasność lampy (ANSI)", "values": ["3000 lm"]}, {"id": "204829", "name": "Rozdzielczość podstawowa (px)", "valuesIds": ["204829_221801"]}, {"id": "225693", "name": "EAN (GTIN)", "values": ["8806092978423"], "options": {"identifiesProduct": true, "isGTIN": true}}, {"id": "224017", "name": "Kod producenta", "values": ["EPSONPROJ123"]} ], "description": { "sections": [ { "items": [ {"type": "TEXT", "content": "

Home Cinema Projector - Bring the cinema experience home.

"} ] } ] }, "language": "pl-PL" }

trace_id: 800e476f0d48e04c

Lukasz-Zurek commented 2 months ago

The structure was ok, but you should correct "content" and add html tags there. I have corrected it and the request is ok. But as I see - the product has been successfuly created.

marcusskelly commented 2 months ago

Great! Thanks for your help :)

hlupec commented 3 weeks ago

Hi, i've got similar problem - same error occures HttpMessageNotReadableException while creating new products. It's wierd that some products are created successfully. This is example of my request (sending to sandbox environment):

{
  "name": "PRESIDENT JFK II",
  "category": {
    "id": 28273
  },
  "parameters": [
    {
      "id": "224017",
      "values": [
        "123456789"
      ]
    },
    {
      "id": "248046",
      "valuesIds": [
        "248046_849079"
      ]
    },
    {
      "valuesIds": [
        "243385_811296"
      ],
      "id": "243385"
    },
    {
      "values": [
        "PRESIDENT JFK II"
      ],
      "id": "237206"
    },
    {
      "values": [
        "3435991108065"
      ],
      "id": "225693"
    }
  ],
  "description": {
    "sections": [
      {
        "items": [
          {
            "type": "TEXT",
            "content": "<p>Lorem ipsum</p>"
          }
        ]
      }
    ]
  },
  "language": "cs-CZ"
}

It would be better if the error was little bit better described :)

hlupec commented 3 weeks ago

I'm, sorry .... it was missing images :) So it's ok and you can ignore my last comment. Even though better error message would be nice :)

Lukasz-Zurek commented 3 weeks ago

@hlupec Thank you. We will try to look at error messages and - if possible - we will try to describe them better.

stale[bot] commented 1 week ago

W tym wątku nie pojawiła się żadna nowa odpowiedź w ciągu 7 dni, dlatego automatycznie oznaczamy go jako przeterminowany. Jeśli w ciągu kolejnych 7 dni nie pojawi się żadna odpowiedź, wątek zostanie zamknięty. Dziękujemy za zaangażowanie w dyskusję i zachęcamy Cię do wypełnienia ankiety dotyczącej naszego wsparcia na forum.


There was no new reply in this thread within 7 days, therefore, we automatically marked it as expired. If no response is received within the next 7 days, this thread will be closed. Thank you for engaging in the discussion. We encourage you to complete our forum support survey.