0

I'm using a java rest client lib for OAuth1.0 authentication to access xero API. This is working fine with GET request and I'm able to receive expected response. But it's not working with POST/PUT request and throwing exception

 oauth_problem=signature_invalid&oauth_problem_advice=Failed%20to%20validate%20signature

Whilst whenever using http with POST/PUT, getting all inventory data in response without pushing new data.

I have tried lot finding out what's wrong with this. Please suggest me how can I solve it out

Thanks in Advance

Dilip
  • 2,271
  • 5
  • 32
  • 52

1 Answers1

0

I'm assuming you are not using the Xero-Java SDK. It might be worth looking at as it is actively being supported by Xero and the community.

https://github.com/XeroAPI/Xero-Java

To answer your question about invalid signatures. I've found that if you can perform a GET successfully, but receive an invalid signature on POST/PUT. You should check your baseURL your are signing.

I've seen the following ....

Incorrect verb used (GET, PUT, POST) Query Params not included ResourceURI not included

Here is a sample baseURL of a POST for a Xero Invoice

POST&https%3A%2F%2Fapi.xero.com%2Fapi.xro%2F2.0%2FInvoices%2F96df0dff-43ec-4899-a7d9-e9d63ef12b19&oauth_consumer_key%3D7OSJAWXXXXXXXXXXXDKLHOTHHHSFY%26oauth_nonce%3DA9DCD74418E6669C96A0A734154A9A2BABD42F13%26oauth_timestamp%3D1502899808%26oauth_token%3DK480GXXXXXXXXXXQUVO2SJ402I%26oauth_version%3D1.0

  • I'm not using xero-java library bcz I'm doing this for Android only. May I ask for more assistance? Actually after url encoding getting invalid url error – Dilip Aug 17 '17 at 08:43
  • unexpected url: https%3A%2F%2Fapi.xero.com%2Fapi.xro%2F2.0%2F/Items – Dilip Aug 17 '17 at 08:55
  • I have used a google lib for oAuth1.0 I have debuged the code and the same way lib generating signature. but it's not working with post request – Dilip Aug 17 '17 at 11:36