Magento – Invalid Signature – add a product using Magento REST API

apimagento-1.7magento-1.8magento-enterpriserest

i have created AccessToken and AccessTokenSecret as mentioned in the Oauth Rest API Documentation and I am able to retrieve the products using GET Request. But when i try to Create a new product (POST Request) using Java, I am always getting "signature_invalid" from magento server.

{"messages":{"error":[{"code":401,"message":"oauth_problem=signature_invalid"}]}}

Here is the Request:

OAuth oauth_nonce="1332732890", oauth_version="1.0", oauth_consumer_key="402ce3406b6d69b74fe7a4b8652bcec1", oauth_signature_method="HMAC-SHA1", oauth_token="f12bbd4012d11f754c1aee4e372ff1db", oauth_timestamp="1402981865", oauth_signature="C6HSsBXzVJ6YahcX3rNzdXlyZuA="

Thanks in advance.

Best Answer

Not sure if this is the problem for you but I had a similar issue the other day.
My problem was actually 2 problems.

  1. The authorization url for admin actions should be ROOT/admin/oauth_authorize not ROOT/oauth/authorize like it is for guest or customer requests.
  2. An admin role should be created in the backend and at least an user must be assigned to it. For that go to System->Web Services->REST Roles click on Add Admin Role.Set the permissions and after the page reloads you should see a tab called Role Users. Click on Reset Search and add at least one admin to the role. Save and try again.

I hope that at least one of the points above solves your problem