Title: problem with REST Api
Last modified: October 26, 2017

---

# problem with REST Api

 *  [cregonat](https://wordpress.org/support/users/cregonat/)
 * (@cregonat)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/problem-with-rest-api-2/)
 * Hello,
 * I’m trying to develop a rest client with api v2. I can get products, categories,
   etc, but I can’t post or put anything. The error I get is this:
 * {“code”:”rest_invalid_json”,”message”:”El cuerpo JSON no v\u00e1lido pas\u00f3.”
   ,”
   data”:{“status”:400,”json_error_code”:4,”json_error_message”:”Syntax error”}}
   c url: (3) [globbing] unmatched close brace/bracket in column 8
 * and this is the curl command:
 * D:\Instaladores\curl>curl -X POST [https://rcsoftware.test/wp-json/wc/v2/products](https://rcsoftware.test/wp-json/wc/v2/products)
   /
   categories -u ck…:cs…. -H “Content-Type: application/json” -d ‘{“name”: “Test
   Category”}’ –insecure
 * Any help?
 * Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [vankaa](https://wordpress.org/support/users/vankaa/)
 * (@vankaa)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/problem-with-rest-api-2/#post-9623812)
 * The error means that your request is not formed correctly. Check your json format.
   According to the message, you have an unmatched close bracket.
 *  Thread Starter [cregonat](https://wordpress.org/support/users/cregonat/)
 * (@cregonat)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/problem-with-rest-api-2/#post-9624256)
 * I know, but I get the same response no matter what json data is sent to the server.
   For example, this happens with the json I take from the docs.:
 * ‘{
    “name”: “Clothing”, “image”: { “src”: “[http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg&#8221](http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg&#8221);}}’
 * thanks
 *  Thread Starter [cregonat](https://wordpress.org/support/users/cregonat/)
 * (@cregonat)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/problem-with-rest-api-2/#post-9624674)
 * well, after some time of trial and error, I’ve found that if I send the json 
   with the ” escaped, and without spaces, it works ok.
 * ej:
 * {\”name\”:\”CategoryOne\”} —> Ok
    {\”name\”:\”Category One\”} —> Fail {“name”:”
   CategoryOne”} —> Fail
 * Any ideas?
 *  [vankaa](https://wordpress.org/support/users/vankaa/)
 * (@vankaa)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/problem-with-rest-api-2/#post-9625941)
 * How are you generating your JSON data? Try using consistent generation may be`
   json_encode` an array and send it then. The API runs a `json_decode` on the body,
   so if the json_encode is used for the encoding you should pass the validation.
 *  Thread Starter [cregonat](https://wordpress.org/support/users/cregonat/)
 * (@cregonat)
 * [8 years, 9 months ago](https://wordpress.org/support/topic/problem-with-rest-api-2/#post-9627725)
 * I’ve generated the json with delphi, but I forgot to convert to utf-8 before 
   send it to the server. Usin curl for test, seems that I copied the json text 
   bad encoded.
    Now it works ok.
 * Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘problem with REST Api’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [cregonat](https://wordpress.org/support/users/cregonat/)
 * Last activity: [8 years, 9 months ago](https://wordpress.org/support/topic/problem-with-rest-api-2/#post-9627725)
 * Status: not resolved