• Resolved php-supadev

    (@lbdeveloper)


    I get a json error when creating products

    An example request body is

    { 	"type" : "variable",
    						"name" : "Centauri COVID-19 Strip Laminated Anti-Slip Floor Vinyl (Set of 12)", 
    						"description" : "<p>Full-colour high-resolution digital print on removable self-adhesive vinyl and laminated with a durable Anti Slip 200 Micron Floor Lamination and machine trim to size.</p>
    <ul>
    <li>assembled: 800 (w) x 80 (h)</li>
    <li>print media: removable self-adhesive vinyl
    <ul>
    <li>120gsm</li>
    </ul>
    </li>
    <li>lamination media weight: 200 micron</li>
    </ul>",
    						"short_description" : "<p>Full-colour high-resolution digital print on removable self-adhesive vinyl and laminated with a durable Anti Slip 200 Micron Floor Lamination and machine trim to size.</p>
    <ul>
    <li>assembled: 800 (w) x 80 (h)</li>
    <li>print media: removable self-adhesive vinyl
    <ul>
    <li>120gsm</li>
    </ul>
    </li>
    <li>lamination media weight: 200 micron</li>
    </ul>",
    						"categories" : [ { "id" : "8039"}], 
    						"sku" : "DISPLAY-0362","attributes" : [  { "id" : "7", "name": "Colour", "position" : 0, "visible" : true, "variation": true, "options" : [ "Blue","Green","Grey","Red","Yellow"]},  { "id" : "8", "name": "Size", "position" : 1, "visible" : true, "variation": true, "options" : [ "default"]} ],"stock_status" : "instock", "images" : [{ "src" : "https:\/\/productcatalogue2015.s3.amazonaws.com\/DISPLAY-0362_260_250.jpg" }],
    						"price" : "275.862",
    						"regular_price" : "275.862"}

    The response i get is `rest_invalid_json
    Invalid JSON body passed. json_error_code 3
    Control character error, possibly incorrectly encoded`

    Indeed i get an error also on json validators, but it’s confusing
    Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'
    This is actually a JSON related question

    What are the wrong control characters in question that cause the error?

    p.s. actually the “<” and “>” characters are replaced by entities in the original request body, here you see them as < and >

    • This topic was modified 3 years, 7 months ago by php-supadev.
    • This topic was modified 3 years, 7 months ago by php-supadev.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support fevered – a11n

    (@fevered)

    Hey there!

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Plugin Support Sol J. a11n

    (@solstudioim)

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – I trust that what Fevered said before points you in the right direction, but if you have more questions, let us know.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[REST API] Invalid JSON when creating product’ is closed to new replies.