我正在尝试进行查询以获取失败的SyncStatus对象。在API资源管理器中,您必须选择“状态”菜单选项以便对其进行测试并将请求提交到https:/// sb / STATUS / v2 /,即使响应XML将其称为SyncStatus ...所以不是确切地说应该准确称之为什么。
但这不是我的问题。我的问题是,当我提交请求(详情如下)时,我收到404错误。它可以在API Explorer中完美地找到,并且在主体中使用完全相同的XML。我一直在调用API,所以我知道我的框架正在运行。
帮助?
请求标题
Content-Length: 322
Authorization:
OAuth
oauth_consumer_key="KEY",
oauth_nonce="NONCE",
oauth_signature="SIG",
oauth_signature_method="HMAC-SHA1",
oauth_timestamp="1377117362",
oauth_token="TOKEN",
oauth_version="1.0"
Content-Type: text/xml
Host: services.intuit.com
Connection: Keep-Alive
请求身体
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><SyncStatusRequest ErroredObjectsOnly="true" xmlns="http://www.intuit.com/sb/cdm/v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.intuit.com/sb/cdm/xmlrequest RestDataFilter.xsd"><OfferingId>ipp</OfferingId></SyncStatusRequest>
响应(添加了一些新行以提高可读性)
<html><head><title>JBoss Web/2.1.12.GA-patch-03 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head>
<body>
<h1>HTTP Status 404 - Null subresource for path: https://internal.services.intuit.com/sb/status/v2/725079435</h1>
<HR size="1" noshade="noshade">
<p>
<b>type</b>
Status report</p><p><b>message</b> <u>Null subresource for path: https://internal.services.intuit.com/sb/status/v2/725079435</u>
</p><p>
<b>description</b>
<u>The requested resource (Null subresource for path: https://internal.services.intuit.com/sb/status/v2/725079435) is not available.</u>
</p>
<HR size="1" noshade="noshade">
<h3>JBoss Web/2.1.12.GA-patch-03</h3>
</body></html>
编辑:我发现我使用的是GET而不是POST。我已修复此问题,但现在我在响应中遇到了不同的错误:
NEW RESPONSE(为了便于阅读添加了新行):
<?xml version="1.0" ?>
<RestResponse xmlns="http://www.intuit.com/sb/cdm/v2">
<Error RequestId="347b6e52b653439493b57db68250b61a">
<RequestName>ErrorRequest</RequestName>
<ProcessedTime>2013-08-21T21:57:50.693Z</ProcessedTime>
<ErrorCode>-2001</ErrorCode>
<ErrorDesc>Premature end of file.</ErrorDesc>
</Error>
</RestResponse>
答案 0 :(得分:3)
刚才,我尝试使用devkit。我正在分享端点和帖子正文。请试一试,让我知道它是否适合您。
必填标题
Content-Type: text/xml
帖子正文
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<SyncStatusRequest ErroredObjectsOnly="true" xmlns="http://www.intuit.com/sb/cdm/v2"/>
另一个 帖子正文(当我传递任何ID时)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<SyncStatusRequest ErroredObjectsOnly="true" xmlns="http://www.intuit.com/sb/cdm/v2">
<NgIdSet>
<NgId>660607</NgId>
<NgObjectType>Customer</NgObjectType>
</NgIdSet>
</SyncStatusRequest>
端点
https://services.intuit.com/sb/status/v2/657117515
Java代码
public void testSyncStatus(String id) {
QBSyncStatusRequest syncStatusRequest = QBObjectFactory.getQBObject(
context, QBSyncStatusRequest.class);
syncStatusRequest.setErroredObjectsOnly(true);
NgIdSet ngIdSet = new NgIdSet();
ngIdSet.setNgId(id);
ngIdSet.setNgObjectType(ObjectName.CUSTOMER);
List<NgIdSet> idSets = new ArrayList<NgIdSet>();
idSets.add(ngIdSet);
syncStatusRequest.setNgIdSet(idSets);
logger.debug("inside testSyncStatus");
try {
QBSyncStatusRequestService service = QBServiceFactory.getService(
context, QBSyncStatusRequestService.class);
List<QBSyncStatusResponse> response = service.getSyncStatus(
context, syncStatusRequest);
System.out.println(response);
Iterator<QBSyncStatusResponse> iterator = response.iterator();
while (iterator.hasNext()) {
QBSyncStatusResponse each = (QBSyncStatusResponse) iterator
.next();
System.out.println(" Message Code - " + each.getMessageCode()
+ " Message Desc - " + each.getMessageDesc());
}
} catch (QBInvalidContextException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
由于