I've a magento 1.9.1 community instance setup and I'm trying to access them via REST API . I'm able to perform GET requests for Products/Customers etc but I'm stuck while adding a product using a POST request. My sample code is below. Where am I going wrong ?
from requests_oauthlib import OAuth1 as OAuth
import requests
import json
oauth = OAuth(client_key=consumer_key,
client_secret=consumer_secret,
resource_owner_key=access_key,
resource_owner_secret=access_secret)
headers = {'Content-Type': 'application/json',
'Accept': 'application/json'}
product = """{
"type_id": "simple", "attribute_set_id": "4", "sku": "Test", "name": "Test", "price": "100", "description": "Random description", "short_description": "Random", "weight": "500", "status": "1", "visibility": "4", "tax_class_id": "2" }"""
payload = json.loads(product)
uri = "http://magentohost/api/rest/products"
r = requests.post(url=uri, data=json.dumps(payload),headers=headers, auth=oauth)
print r