Getting error "expected String to be a Integer"

Topic summary

  • Problem: Fetching products via the Shopify REST API with the since_id parameter triggered a runtime error: “expected String to be a Integer,” even after converting the value to an integer.

  • Context: since_id is a query parameter used to return products with IDs greater than the provided one (pagination).

  • Cause: The parameter was appended in the request path/URL instead of being passed as a query/search parameter, leading the client/SDK to mis-handle the type.

  • Resolution: Pass since_id through the client’s query options (searchParams) on the GET call, ensuring it’s a number (e.g., parseInt of the last product’s ID). After this change, the request succeeds.

  • Outcome: Issue resolved; no further questions or disagreements.

  • Notes: Screenshots and a code snippet were included to show the error and the corrected request approach.

Summarized with AI on December 27. AI used: gpt-5.

Hi! When i try to get products info using RESTP API, i parse the last product id with parameter “since_id” to of course, get the other products since the mentioned one. When i execute the code, i get an error saying that “expected String to be a Integer”. I’ve already checked the type of variable and of course, convert it to Int but I keep getting the same error.

Screenshot_2.png

And my code:

Finally I found how to solve it!

Here is how (you need to parse another parameter to get method instead of apply the parameter in the “path”):

response = await shopifyClient.get(“/products”, { searchParams: { since_id: parseInt(finalResult[finalResult.length - 1].id) } });