Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Create a new product using REST API

 
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 12-14-2016, 05:13 AM
 
CarterMarter CarterMarter is offline
 

Newbie
  
Join Date: Dec 2016
Posts: 2
 

Default 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 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
Code:
https://some-address/admin.php?target=RESTAPI&_key=my-write-key&_path=product
I receive a JSON array of product descriptions.

Am I doing something wrong?
REST API version: 5.3.2
XCART version: 5.3.1.6 Rev0
__________________
REST API 5.3.2
XCART 5.3.1.6 Rev0 Bitnami Windows
Reply With Quote
  #2  
Old 12-22-2016, 05:59 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default 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)?
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #3  
Old 12-22-2016, 06:36 AM
 
CarterMarter CarterMarter is offline
 

Newbie
  
Join Date: Dec 2016
Posts: 2
 

Default 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! 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):
Code:
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Encoding:gzip, deflate, sdch Accept-Language:en-US,en;q=0.8,bg;q=0.6,ru;q=0.4,es;q=0.2 Connection:keep-alive 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 Host:---.---.---.---:---- If-Modified-Since:Thu, 22 Dec 2016 06:19:09 -0800 If-None-Match:37a6259cc0c1dae299a7866489dff0bd Upgrade-Insecure-Requests:1 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):
Code:
Connection:Keep-Alive Date:Thu, 22 Dec 2016 14:22:52 GMT ETag:37a6259cc0c1dae299a7866489dff0bd Keep-Alive:timeout=5, max=100 Server:Apache Set-Cookie:xid=GQMVUKjlmet8lFjNfcnS6gi5krDhyuCY; path=/; domain=---.---.---.---; httponly Vary:Cookie

I have the same situation when issuing the request from a program.
__________________
REST API 5.3.2
XCART 5.3.1.6 Rev0 Bitnami Windows
Reply With Quote
  #4  
Old 12-22-2016, 07:07 AM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default 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.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > General questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 04:06 PM.

   

 
X-Cart forums © 2001-2020