Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Webhook order/paid JSON invalid when line_item name contains a quote.

Solved

Webhook order/paid JSON invalid when line_item name contains a quote.

samuel_webster_
Shopify Partner
5 0 1

I'm receiving a webhook json with the following line item.

This item has a quotation mark in it's title, and the keen eye will notice  "name": "Thing that is inches long - Standard / 1"".

 

This isn't valid JSON since the product titles " isn't escaped with a backward slash.

 

 

{
  "id": 12345,
  "admin_graphql_api_id": "gid://shopify/LineItem/12345",
  "attributed_staffs": [],
  "current_quantity": 1,
  "fulfillable_quantity": 1,
  "fulfillment_service": "manual",
  "fulfillment_status": null,
  "gift_card": false,
  "grams": 26,
  "name": "Thing that is inches long - Standard / 1"",
  "price": "17.39",
  "price_set": {
    "shop_money": {
      "amount": "17.39",
      "currency_code": "USD"
    },
    "presentment_money": {
      "amount": "17.39",
      "currency_code": "USD"
    }
  }
}

 

I imagine this issue must occur if customers type a quote in their checkout information too, like a house name, or such. Has anyone else run into this issue?

Accepted Solution (1)

SBD_
Shopify Staff
1831 273 423

This is an accepted solution.

Hey @samuel_webster_ 

 

That's strange, it should be escaped. How are you parsing the JSON? Can you try/confirm with https://webhook.site ?

Scott | Developer Advocate @ Shopify 

View solution in original post

Replies 2 (2)

SBD_
Shopify Staff
1831 273 423

This is an accepted solution.

Hey @samuel_webster_ 

 

That's strange, it should be escaped. How are you parsing the JSON? Can you try/confirm with https://webhook.site ?

Scott | Developer Advocate @ Shopify 

samuel_webster_
Shopify Partner
5 0 1

Yeah, webhook raw confirms it is. I'm not unescaping through, I'm capturing raw input and chucking it into a db to deal with later. MySQL must be unescaping it on insert or something, thanks for the idea to check it raw elsewhere.