X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   General questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=66)
-   -   Create a new product using REST API (https://forum.x-cart.com/showthread.php?t=74791)

CarterMarter 12-14-2016 05:13 AM

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:

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 intervals in [ code ] are to make the BBCode happy with formatting. Just ignore them)
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

I receive a JSON array of product descriptions.

Am I doing something wrong?
REST API version: 5.3.2
XCART version: Rev0

qualiteam 12-22-2016 05:59 AM

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):

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)?

CarterMarter 12-22-2016 06:36 AM

Re: Create a new product using REST API
Thank you for your response. The only suspicious log I find is in the access log:

[ 06:19:10.000000 ] Controller class  not found!
Runtime id: a3c8b2b58123395330222b2046272cac
SAPI: apache2handler; IP: IP.IP.IP.IP
URI: /favicon.ico
Method: GET

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):

Accept-Encoding:gzip, deflate, sdch
Cookie:LCRefererCookie=http%3A%2F%2F192.168.1.34%3A81%2Fbitnami%2Findex.html; mage-messages=%5B%5D; recent_login=some-login; xid_admin_logged=admin_logged; xid=GQMVUKjlmet8lFjNfcnS6gi5krDhyuCY
If-Modified-Since:Thu, 22 Dec 2016 06:19:09 -0800
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36

Response 304 (Not modified):

Date:Thu, 22 Dec 2016 14:22:52 GMT
Keep-Alive:timeout=5, max=100
Set-Cookie:xid=GQMVUKjlmet8lFjNfcnS6gi5krDhyuCY; path=/; domain=---.---.---.---; httponly

I have the same situation when issuing the request from a program.

qualiteam 12-22-2016 07:07 AM

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 01:01 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.