Unable to create(POST) objects (Account, customer…

2019-08-04 08:31发布

问题:

Here I am provideing you the complete scenario where I am getting the error while posting request for creating a new account.

I am using Intuit OAuth Access and OAuth API console for testing (Using all security tokens).(https://appcenter.intuit.com/Playground/OAuth)

And the URL and request:

URL: https://services.intuit.com/sb/account/v2/570357960

Method : Post

Format: XML/JSON

Request:

<?xml version="1.0" encoding="UTF-16"?><Add xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" RequestId="4df87bw2-916a-

4r95-h5d6-06dce3667562" 

xmlns="http://www.intuit.com/sb/cdm/v2"><ExternalRealmId>570357960</ExternalRealmId><Objectxsi:type="Account"><Name>CurrentAccount</Name><Active>true</Active><Type>Expense<

/Type><Subtype>Expense</Subtype><AcctNum>1111</AcctNum></Object></Add>

And getting the response (error in html):

 <div class="content-container"><fieldset>
  <h2>500 - Internal server error.</h2>
  <h3>There is a problem with the resource you are looking for, and it cannot be displayed.</h3>

and I have also checked with RESTClient utility, but getting the same above error.

Please note that the same url (https://services.intuit.com/sb/account/v2/570357960) with same security tokens is working fine for GET data , I am getting data from QB desktop into my online Application.

回答1:

As Keith said, check the Content-Type. You will also need to use a RestClient for testing. The playground will not work for testing API calls. It only works for platform calls.



回答2:

If I had to guess... I'd guess you're sending the wrong Content-Type header... but it's impossible to tell for sure until you post more code/the rest of your HTTP request.



回答3:

A few things to try. Be sure the XML is in the same order as this sample and try it. the other is a common mistake when you use Oauth in a GET you are including just the url in the signature, but in a POST you need to include the Body in the signature too or it will not pass Oauth validation.

Lastly, as Keith mentioned to check the content type. Although you would generally get a content type error.

156234822 CurrentAccount true Expense Expense 1111