Closed hasithaarimac closed 4 years ago
Hello thanks for reporting the issue. We definitely need to revise the documentation for that.
The id you are looking for is the Id of the shipping method. This can be aquired by using the GET /checkout/{token}/shipping
endpoint.
Hi mamazu,
Thank you for the quick response. As per the "GET /checkout/{token}/shipping" endpoint response, there is no ID for a shipping method. It has only code and a name. So I tried out the "Choosing a cart shipping method" using the shipment method code but still I'm getting the same response from the server. Please check the below response from the server,
Response message
{ "code": 500, "message": "Can not find shipment with given identifier." }
Response - GET /checkout/{token}/shipping Endpoint
{ "shipments": [ { "methods": { "shippingMethod": { "code": "shippingMethod", "name": "shippingMethod", "price": { "current": 10000, "currency": "USD" } } } } ] }
Also, we're sending the shipping method again in the request body too. Please check the attached screenshots.
These are the versions that we're using now.
Sylius - 1.7.0 (Latest) Sylius Documentation - 1.7 Sylius shop API - 1.1 (Latest) Sylius shop Documentation - 1.0.0
Hi,
https://github.com/Sylius/ShopApiPlugin/issues/649#issuecomment-633524599
Same with payment method. Best,
Paul
The response of the get endpoint is correct. It looks like you only have one shipping method set up so if you want to use it you need the "id" to be 0
. The id (which is usually short for identifier) is in this case the index in the response.
Hi Mamazu,
Thanks for the response again. We tried with the position code of the shipping method and still getting the same issue.
{ "code": 500, "message": "Can not find shipment with given identifier." }
Actually, there are 5 shipping methods available (Check the below postman screenshot). The "position ID" of the selected method is "3".
Please find the below curl of the request.
curl --location --request PUT 'http://{host}/shop-api/checkout/b56ceb12-969c-4c53-aa08-65ab6821580e/shipping/3' \
--header 'Content-Type: application/json' \
--data-raw '{
"method": "shippingMethod"
}'
Please find the below screenshots of the admin panel and the request body as well.
Can you try 0 as the id? (This should work).
If not can you please provide a stack trace on where this error is happening?
@hasithaarimac you're using wrong index. Over here index is a position of shipment
element in the cart-summary json output. Usually it will be 0
and it's not related to shipping method in the admin panel.
If it still doesn't work, I gather from your other ticket, that you have shipping_skipped
state and no shipments in your cart, then this is your issue and you need to fix it first.
@diimpp @mamazu Thanks for the valuable inputs. Seems like I used the wrong index to add the shipping method to the cart. Now it works well. Thanks for the help guys. cheers!
Guys, I need a little help from you. Currently, I need to set a shipping method for my order. For that, I executed the first 3 endpoints of the Checkout flow in a sequence way and Those were succeeded. But for the 4th endpoint, there is a required parameter called "ID" in the payload (as per my understanding it asks for an order ID). So from where can we find the order ID of the current order? Is there any specific endpoint should we need to try out to get the order ID? Please help me to get a solution for this. Thank you
Endpoint : Choosing a cart shipping method endpoint (/checkout/:token/shipping/:id)