AcctNum 不是 QBO 帐户实体的有效过滤器。
参考 - https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0400_quickbooks_online/account#Attributes_Supporting_Filtering_and_Sorting
您可以使用“名称”属性作为过滤器。
PFB 代码片段
使用 java 开发工具包
public List<QBAccount> testGetAll() {
QBAccountQuery accountQuery = new QBAccountQuery(context);
accountQuery.setName("BankCharges");
final List<QBAccount> entityList = new ArrayList<QBAccount>();
try {
QBAccountService service = QBServiceFactory.getService(context, QBAccountService.class);
List<QBAccount> qbAccountList = service.getAccounts(context, accountQuery);
for (QBAccount each : qbAccountList) {
entityList.add(each);
}
} catch (QBInvalidContextException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return entityList;
}
端点 - https://qbo.intuit.com/qbo1/resource/accounts/v2/188712345
内容类型:application/x-www-form-urlencoded
将数据发布到端点:Filter= Name :EQUALS: BankCharges
使用路标
public class PocApiCall {
static String accesstoken = "";
static String accessstokensecret = "";
static String appToken = "";
static String oauth_consumer_key = "";
static String oauth_consumer_secret = "";
static String realmID = "";
static String dataSource = "";
static String url = "";
PocApiCall() {
setupQBO();
}
public static void main(String args[]) {
PocApiCall apiCall = new PocApiCall();
apiCall.testLikeDevkit();
}
private void testLikeDevkit() {
HttpClient client = new DefaultHttpClient();
HttpPost requestHp = new HttpPost(url);
requestHp.addHeader("Content-Type", "application/x-www-form-urlencoded");
BasicHttpEntity filter = new BasicHttpEntity();
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("Filter", "Name :EQUALS: BankCharges"));
requestHp.setEntity(new UrlEncodedFormEntity(nameValuePairs,"UTF-8"));
CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer(oauth_consumer_key, oauth_consumer_secret);
consumer.setTokenWithSecret(accesstoken, accessstokensecret);
consumer.sign(requestHp);
debugRequestValues(requestHp);
HttpResponse execute = client.execute(requestHp);
System.out.println(new BufferedReader(new InputStreamReader(execute.getEntity().getContent())).readLine());
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (OAuthMessageSignerException e) {
e.printStackTrace();
} catch (OAuthExpectationFailedException e) {
e.printStackTrace();
} catch (OAuthCommunicationException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
private void debugRequestValues(HttpPost requestHp) throws IOException {
System.out.println("Method - " + requestHp.getRequestLine().getMethod());
System.out.println("URI - " + requestHp.getRequestLine().getUri());
Header[] allHeaders = requestHp.getAllHeaders();
for(Header h : allHeaders){
System.out.println("Name - " + h.getName() + " Value - " + h.getValue());
}
if(requestHp.getEntity() != null){
System.out.println(new BufferedReader(new InputStreamReader(requestHp.getEntity().getContent())).readLine());
}
}
private static void setupQBO() {
System.out.println("QBO token setup");
accesstoken = "your tokens";
accessstokensecret = "your tokens";
appToken = "your tokens";
oauth_consumer_key = "your tokens";
oauth_consumer_secret = "your tokens";
realmID = "688779980";
dataSource = "QBO";
url = "https://qbo.intuit.com/qbo1/resource/accounts/v2/123459980";
}
}
谢谢