It means the line_item_id is the Shopify GraphQL global ID rather than the numeric REST ID. The API expects a gid formatted string when using calculateRefund. Retrieving the order through GraphQL and providing the line item gid, then the refund calculation does not fail with the 400 error.
The error message “expected String to be a id” indicates that the Shopify API is receiving an ID in a format it cannot process, typically because a numerical value was sent where a string (text) was expected. While Shopify IDs look like numbers, the GraphQL and REST APIs often require them to be passed as strings within the payload
In your specific calculate_payload, the line_item_id is currently set as an integer (123456777777). To fix the 400 error, you should wrap that ID in quotation marks so it is treated as a string ("123456777777").
Additionally, ensure that the shopify_order_id in your broader user context is also handled as a string if it is being passed as a variable in the same request.