allegro / allegro-api

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

creating test offers on allegro sandbox #3731

Closed ahmed624 closed 3 years ago

ahmed624 commented 3 years ago

Hello everyone,

I have a seller's account at allegro and I have registered and integrated my app with at the allegro sandbox and I am able to fetch application, user tokens.

now i want to create a couple of test orders at allegro sandbox so that i can test the downloading,dispatch, refund of orders through my app.

can you tell me how to post test orders on allegro? they say that i need to create some offers first to place order against. i have been trying to create offers through POSTMAN but it returns json parsing error. can someone send me a sample json to create a basic offer with a new product that is not in their database. and how can i then post orders against those offers to test the order APIs.

AureliuszBrussy commented 3 years ago

Sorry, but I cannot find the answer to why you get 400 Bad request - your payload and header seems valid. Are you sure that request looks exactly like from sent example?

As for the questions:

  1. You can create new products and assign this product to many offers. Read more here.
  2. You can use existing products created by other sellers. Just retrieve data of existing product via GET /sale/products?ean={ean}. Please, check our guide for more info. Then, if you found the right product - you can list an offer assigned to a product with one request via POST /sale/product-offers.
  3. If you try to create a product that already exists - you will get an error with information about an existing product.
ahmed624 commented 3 years ago

yes i am sure the request was the same. will make another test with non 0 amount and let you know the results.

about point 3. how does allegro identify that a product exists ? using the product id? or title? is the product id unique across marketplace i mean across multiple seller.

ahmed624 commented 3 years ago

Hi Brussy, i made another request for update prices as follows;

uri : https://api.allegro.pl.allegrosandbox.pl/sale/offer-price-change-commands/1cc26084-1bc0-49f1-8ee7-841a84277784

request data:

{"modification":{"type":"FIXED_PRICE","price":{"amount":"10","currency":"PLN"}},"offerCriteria":[{"offers":[{"id":"7678669681"}],"type":"CONTAINS_OFFERS"}]}

Response:

HTTP Status Code: 400 org.springframework.web.client.HttpClientErrorException$BadRequest: 400 Bad request: [

400 Bad request

Your browser sent an invalid request.

do you want the token that i used for this request?

ahmed624 commented 3 years ago

one more interesting observation Brussy, when I try to perform the same request through postman, PFA details. it returns 0 in success but when i checked the offer details were updated according to the sent price through postman : / shouldnt success be 1? and its not working without postman anyway as i mentioned in the previous comment. Screenshot from 2020-10-15 13-42-22

AureliuszBrussy commented 3 years ago

Allegro identifies that the product exists base on the EAN and other parameters that uniquely identify the product.

The price change command works asynchronously, so to get its result use GET /sale/offer-price-change-commands/{commandId} or GET /sale/offer-price-change-commands/{commandId}/tasks. Use the same commandId as in the PUT method.

As you can see - the command works fine in Postman, it seems like the problem is with your implementation.

ahmed624 commented 3 years ago

okay thanks let me check the headers and stuff.

ahmed624 commented 3 years ago

yes its working fine now. thanks Brussy, i'll finalize all the APIs before passing them on to our QA. will get back to you on this thread if there is any other missing piece. cant thank you enough for your support.

stale[bot] commented 3 years ago

W tym wątku nie pojawiła się żadna nowa odpowiedź w ciągu 30 dni. Dlatego automatycznie oznaczamy go jako przeterminowany. Jeśli w ciągu 7 dni nie pojawi się żadna odpowiedź, zamkniemy ten wątek. Dziękujemy za zaangażowanie w dyskusję.

ahmed624 commented 3 years ago

Hi Brussy,

We are in the process our releasing our Allegro connector App to our customers, can you please confirm that the same app credentials (token) can be shared across our customers? or does every customer needs to have a separate app?

AureliuszBrussy commented 3 years ago

One app can be used by multiple customers. You do not need to create a separate application (Client_ID).

ahmed624 commented 3 years ago

oh okay so what I understand is that the same client id (auth url basically) can be used by multiple customers and allegro will issue different access tokens to them -to uniquely identify which seller is calling the API?

AureliuszBrussy commented 3 years ago

Yes, exactly, every user will get unique access tokens.

ahmed624 commented 3 years ago

thanks Brussy, you have been great help. will seek your guidance from time to time during this production roll out process.

ahmed624 commented 3 years ago

Hi Brussy,

I am trying to list to allegro as follow;

uri: https://api.allegro.pl.allegrosandbox.pl/sale/product-offers

just the authorization header is being sent containing the bearer token.

but the response is as follows;

HTTP Status Code: 406

{"errors": [{"code":"NotAcceptableException", "message":"Not acceptable representation requested. Please check 'Accept' request header"," details":null,"path":null, "userMessage":"The request contains incorrect data. Contact the author of the application."}]}

can you tell me why this error comes when i am not sending any accept header at all : /

AureliuszBrussy commented 3 years ago

In this case, you need to include in you request 2 additional headers (besides authorization header):

ahmed624 commented 3 years ago

okay thanks Brussy.We are in the QA stage at the moment so just testing different scenarios.

ahmed624 commented 3 years ago

Hi Brussy,

We are in the phase of QA and trying to list a product through our customer application but allegro is rejecting the html in description can you please tell the reason mate. the details are;

uri used : https://api.allegro.pl.allegrosandbox.pl/sale/product-offers

Data sent to allegro: { "sellingMode": { "format": "BUY_NOW", "price": { "amount": "1.99", "currency": "PLN" } }, "stock": { "available": 1, "unit": "UNIT" }, "publication": { "status": "ACTIVE" }, "images": [ "http://images.esellerpro.com/10101/I/89/TEST.png" ], "description": { "sections": [ { "items": [ { "type": "TEXT", "content": "\n \n \n \n<style type=\"text/css\">\n\nBASE_SIZE 14\nBASE_SIZE 14 BASE_SIZE 14 BASE_SIZE 14 BASE_SIZE 14 BASE_SIZE 14 BASE_SIZE 14 BASE_SIZE 14 BASE_SIZE 14 BASE_SIZE 14 BASE_SIZE 12 BASE_SIZE 12 BASE_SIZE 14 BASE_SIZE 14 BASE_SIZE 14 BASE_SIZE 14 BASE_SIZE 14 BASE_SIZE 14 BASE_SIZE 14 BASE_SIZE 14 \n\n\n\n \n

\n This is a car sticker.\n

\n\n

\n \n

\n\n

\n Test listing, please do not buy.\n

\n\n \n\n\n\n" } ] } ] }, "name": "Car Sticker - Test Do Not Buy", "external": { "id": "Marketplace-CarSticker1" }, "product": { "ean": "5093265586551", "name": "Car Sticker - Test Do Not Buy", "category": { "id": "253778" }, "images": [ "http://images.esellerpro.com/10101/I/89/TEST.png" ], "parameters": [ { "id": "11323", "values": [ "11323_1" ] } ] }, "delivery": { "shippingRates": { "id": "a1b813f2-dd32-488b-bc60-fb9eee59f15b" } } }

headers:

{"Accept":"application/vnd.allegro.beta.v2+json","Content-Type":"application/vnd.allegro.beta.v2+json"}

Response from Allegro:

422 Unprocessable Entity: [{"errors":[{"code":"VALIDATION_ERROR","message":"Invalid tag \"html\", expected one of {h1, h2, p, ul, ol}","details":"Invalid value: \n \n \n \n<style type=\"text/css\">\n\nBASE_SIZE... (778 bytes)]

AureliuszBrussy commented 3 years ago

You can use in description only the following HTML tags:

If any other HTML tags appear in the description - we will return error 422.

You can read more about offer content in our guide.

ahmed624 commented 3 years ago

okay thanks Brussy. will trim the html accordingly.

ahmed624 commented 3 years ago

Hi Brussy, so after sorting out the html issue. now something seems to be causing issues with category feature data.

Request:

{"sellingMode":{"format":"BUY_NOW","price":{"amount":"1.99","currency":"PLN"}},"stock":{"available":0,"unit":"UNIT"},"publication":{"status":"ACTIVE"},"images":["http://images.esellerpro.com/10101/I/89/TEST.png"],"description":{"sections":[{"items":[{"type":"TEXT","content":"

This is a car sticker

\n

Test listing, please do not buy.

"}]}]},"name":"Car Sticker - Test Do Not Buy","external":{"id":"Marketplace-CarSticker1"},"product":{"ean":"5093265586551","name":"Car Sticker - Test Do Not Buy","category":{"id":"253778"},"images":["http://images.esellerpro.com/10101/I/89/TEST.png"],"parameters":[{"id":"11323","values":["11323_1"]}]},"delivery":{"shippingRates":{"id":"a1b813f2-dd32-488b-bc60-fb9eee59f15b"}}}

Response:

422 Unprocessable Entity: [{"errors":[{"code":"ParameterCategoryException","message":"Unprocessable Entity","details":null,"path":"","userMessage":"Given parameter id 11323:State should no have been passed as product parameter."}]}]

can you please guide me what needs to be changed here?

ahmed624 commented 3 years ago

Brussy I forgot to mention the URI used, its;

uri:https://api.allegro.pl.allegrosandbox.pl/sale/product-offers

AureliuszBrussy commented 3 years ago

You should pass "State" parameter (id 11323) outside of the "product" object. This is one of the offer parameters. Please, check our guide, where we write about offer parameters (with example).

ahmed624 commented 3 years ago

thanks Brussy but how do we know that which parameter is offer based and which one is product based?

do you have any examples for both of them please?

AureliuszBrussy commented 3 years ago

You can find out which parameters are for offer and which for product in the response for GET /sale/categories/{categoryID}/parameter in options.describesProduct field:

Product and offer parameters occur in most of the categories.

ahmed624 commented 3 years ago

Hi Brussy,

A question about the partial refunds at Allegro, our QA tried to perform a partial refund. following is the detail;

uri:

https://api.allegro.pl.allegrosandbox.pl/payments/refunds

Request:

{ "payment": { "id": "27b0bb21-ad98-11eb-9b9b-25084ea5abc7" }, "reason": "PAID_VALUE_TOO_LOW", "lineItems": [ { "id": "271e6630-ad98-11eb-ac8a-559691003704", "type": "QUANTITY", "quantity": 1 } ], "delivery": { "value": { "amount": "0.0", "currency": "PLN" } }, "additionalServices": { "value": { "amount": "0.0", "currency": "PLN" } } }

Response:

{ "id": "3d1a5329-adc5-11eb-b1b9-d758640af4f3", "payment": { "id": "27b0bb21-ad98-11eb-9b9b-25084ea5abc7" }, "reason": "PAID_VALUE_TOO_LOW", "status": "NEW", "createdAt": "2021-05-05T17:13:41.362Z", "totalValue": { "amount": "2.00", "currency": "PLN" }, "lineItems": [ { "id": "271e6630-ad98-11eb-ac8a-559691003704", "type": "QUANTITY", "quantity": 1 } ], "surcharges": [

] }

We tried to perform a partial refund by quantity by providing the item id and its quantity but the entire item was refunded on Allegro. Can you please guide here?

ahmed624 commented 3 years ago

is there something that we need to change here for the partial refunds Brussy?

AureliuszBrussy commented 3 years ago

If you want to refund only a partial amount - you should set "AMOUNT" type in lineItems[].type field and and instead of the lineItems[].quantity, you should use lineItems[].amount field. Please check our guide to get more details.

ahmed624 commented 3 years ago

so now my understanding is that partial refunds can be performed by amount only and not by quantity?

AureliuszBrussy commented 3 years ago

If you indicate the quantity, we will refund the full amount client paid for the item.

stale[bot] commented 3 years ago

W tym wątku nie pojawiła się żadna nowa odpowiedź w ciągu 30 dni. Dlatego automatycznie oznaczamy go jako przeterminowany. Jeśli w ciągu 7 dni nie pojawi się żadna odpowiedź, zamkniemy ten wątek. Dziękujemy za zaangażowanie w dyskusję.

ahmed624 commented 3 years ago

Hi Brussy, hope you are well. We are planning to move our allegro connector application to the beta release but there is this problem while listing the product. As I understand it we first have to create the offer using

uri: https://api.allegro.pl.allegrosandbox.pl/sale/product-offers

data: {"sellingMode":{"price":{"amount":"1.99","currency":"PLN"}},"stock":{"available":1},"images":["http://images.esellerpro.com/10101/I/89/TEST.png"],"product":{"id":"7fa4fe29-9f21-4113-8428-df1c22d98ae6"}}

headers: {"Accept":"application/vnd.allegro.beta.v2+json","Accept-Language":"en-US","Content-Type":"application/vnd.allegro.beta.v2+json"}

and its working fine the offer gets created and we receive the offer id successfully but after that my understanding is that Allegro requires us to activate the offer as well as a second step is that correct?

and when we try to activate the same offer using;

uri: https://api.allegro.pl.allegrosandbox.pl/sale/offer-publication-commands/c0bfda41-4c35-445d-a8d1-18a8d7ac7278

data: {"offerCriteria":[{"offers":[{"id":"7680722979"}],"type":"CONTAINS_OFFERS"}],"publication":{"action":"ACTIVATE"}}

header:

"Accept":"application/vnd.allegro.beta.v2+json","Accept-Language":"en-US","Content-Type":"application/vnd.allegro.beta.v2+json"}

the following is the response that we are getting;

406 Not Acceptable: [{"errors":[{"code":"NotAcceptableException","message":"Not acceptable representation requested. Please check 'Accept' request header","details":null,"path":null,"userMessage":"The request contains incorrect data. Contact the author of the application."}]}]

can you please guide if this activation is mandatory or not as we can see the offer active in the GUI already and what header am I missing in this offer activation call?

Appreciate your prompt response like always Brussy.

AureliuszBrussy commented 3 years ago

If you are using /sale/product-offers resource to list offer - you do not need to activate it by using PUT /sale/offer-publication-commands/{commandId}. The offer will be automatically activated. You can read more about it in our guide.

You need to use the publication command only when using another resource to create an offer: POST /sale/offers.

ahmed624 commented 3 years ago

thanks Brussy.... yes I have removed this from our product creation process. just wanted to confirm that if a product has variants then is it mandatory to perform the second step to combine the offers once they are created ?

AureliuszBrussy commented 3 years ago

Yes, you should use POST /sale/offer-variants to combine offers.

ahmed624 commented 3 years ago

yes okay thanks mate I have been trying to fetch the categories using

uri:

https://api.allegro.pl.allegrosandbox.pl/sale/categories

headers:

("Accept", "application/vnd.allegro.beta.v2+json"); ("Content-Type", "application/vnd.allegro.beta.v2+json"); ("Accept-Language", "en-US");

Response:

406 Not Acceptable: [{"errors":[{"code":"NotAcceptableException","message":"Not acceptable representation requested. Please check 'Accept' request header","details":null,"path":null,"userMessage":"The request contains incorrect data. Contact the author of the application."}]}]

i dont know what went wrong but it was workign fine : /

PrzemyslawLukanowski commented 3 years ago

Hello @ahmed624 - it's because you are using "application/vnd.allegro.beta.v2+json" in your headers. To use this resource you should provide "application/vnd.allegro.public.v1+json".

ahmed624 commented 3 years ago

okay thanks Przemy and Brussy for your support. we are nearing a beta launch, order APIs are already tested, category params and product creation plus updates are being tested.

ahmed624 commented 3 years ago

moreover it has been noticed that when er download the categories using the headers you mentioned and the

uri: https://api.allegro.pl.allegrosandbox.pl/sale/categories

I assume it should return all the categories but

its not returning some categories like;

    {
        "id": "ea5b98dd-4b6f-4bd0-8c80-22c2629132d0",
        "name": "Fashion",
        "parent": null,
        "leaf": false,
        "options": {
            "variantsByColorPatternAllowed": true,
            "advertisement": false,
            "advertisementPriceOptional": false,
            "offersWithProductPublicationEnabled": false,
            "productCreationEnabled": false,
            "customParametersEnabled": true
        }
    },

can you think of the reason why some categories are not returned ?

AureliuszBrussy commented 3 years ago

You need to use GET /sale/categories?parent.id={categoryId} to retrieve a list of subcategories that belong to the category provided as parent.id parameter. If you use GET /sale/categories without providing any category, you will retrieve only IDs of the main Allegro categories. Use the identifiers to get to the lowest tier category (marked as "leaf": true).