shopify-api-js icon indicating copy to clipboard operation
shopify-api-js copied to clipboard

Price Rule Delete Error

Open xiddixaid opened this issue 4 years ago • 4 comments

Issue summary

When I try to delete Price Rule with Admin API following the documentation mentioned over this link https://shopify.dev/api/admin-rest/2021-10/resources/pricerule#[delete]/admin/api/2021-10/price_rules/{price_rule_id}.json . It deletes my Price Rule from shopify but also through this error Failed to make Shopify HTTP request: FetchError: invalid json response body at https://example.myshopify.com/admin/api/2021-10/price_rules/1058298364037.json reason: Unexpected end of JSON input

Expected behavior

Successful response after deletion of the Price Rule.

Actual behavior

Deletes the Price Rule from Shopify Store but also through invalid json error.

Steps to reproduce the problem

  1. Delete Price Rule with shopify-node-api (rest)

Reduced test case

Properly handle JSON response data with shopify-node-api

xiddixaid avatar Jan 01 '22 08:01 xiddixaid

I got same error on deleting recurring application charge.

dek1chan avatar Jan 06 '22 20:01 dek1chan

I got same error on deleting recurring application charge.

Actually, this error occur when Shopify did not return any response and this app handling response with response.json(). According to Shopify Admin API REST its returns nothing 'No Content' on deletion of PriceRule and Coupon.

You can avoid this error by just making some changes to this file node_modules/@shopify/shopify-api/dist/clients/http_client/http_client.js.

replace 169 line : case 0: return [4 /yield/, response.json()]; with this line: case 0: return [4 /yield/, response.status !== 204 ? response.json() : response];

xiddixaid avatar Jan 20 '22 06:01 xiddixaid

21 May, still not fixed. Do everyone has to waste 5 hours for just to learn this?

umutsesen avatar May 21 '22 22:05 umutsesen

@xiddixaid Thank you.

It's nuts this lib has such a basic bug :facepalm:

ChrisGibb avatar May 25 '22 18:05 ChrisGibb

This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days.

github-actions[bot] avatar Oct 06 '22 02:10 github-actions[bot]

This is still an issue. Experiencing it as well.

zwagner86 avatar Oct 18 '22 19:10 zwagner86

This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days.

github-actions[bot] avatar Jan 31 '23 02:01 github-actions[bot]

We are closing this issue because it has been inactive for a few months. This probably means that it is not reproducible or it has been fixed in a newer version. If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.

If you still encounter this issue with the latest stable version, please reopen using the issue template. You can also contribute directly by submitting a pull request– see the CONTRIBUTING.md file for guidelines

Thank you!

github-actions[bot] avatar Feb 14 '23 02:02 github-actions[bot]