Create a new product using REST API
I am trying to create a new product using the REST API. I use the demo in a browser:
Code:
https://some-address/admin.php?target=RESTAPI&_key=my-write-key&_path=product/0&method=post&model[sku]=sweatshirt&model[price]=10.00&model[amount]=100&model[translations][0][ code ]=en&model[translations][0][name]=sweatshirt The response only says null, with no error indications and the new product is not available in the catalog or in the database. If I do Code:
https://some-address/admin.php?target=RESTAPI&_key=my-write-key&_path=product Am I doing something wrong? REST API version: 5.3.2 XCART version: 5.3.1.6 Rev0 |
Re: Create a new product using REST API
I've tried it on my local computer and it has created a new product and responded with a JSON info about the new product (including its product_id):
http://devs.x-cart.com/en/basics/rest_api_documentation.html#creating-product Do you see any error messages in the var/log/ directory? Also, do you see any error messages in the JavaScript console in your browser when you open the URL? Are you sure that you use the correct key (that is allowed to write data to the database)? |
Re: Create a new product using REST API
Thank you for your response. The only suspicious log I find is in the access log:
Code:
[ 06:19:10.000000 ] Controller class not found! I doublechecked that I am using the read/write key. I also made sure that the read-only key and the read/write key are not the same. The only string I receive in the response stream is this null. I am pasting the request and response headers here (sensitive information masked): Request (when in browser): Code:
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Response 304 (Not modified): Code:
Connection:Keep-Alive I have the same situation when issuing the request from a program. |
Re: Create a new product using REST API
It sounds like the server returns some cached empty response, but I'm not sure why this may happen, unfortunately.
I think you should contact our support staff by submitting a ticket at https://secure.x-cart.com/ - they can check it right on your server. |
All times are GMT -8. The time now is 08:08 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.