我试图在Concur中创建一个用户。我参考了这个职位来获取Xml格式。
这是http POST请求(使用POSTMAN),
请求
POST https://www.concursolutions.com/api/user/v1.0/users HTTP/1.1
Authorization: OAuth 0_xxxxxxxtoF3bsxxxBrNwzxxxx=
Accept: application/xml
Content-Type: application/xml; charset=utf-8
Host: www.concursolutions.com
Content-Length: 227
Expect: 100-continue
<Batch xmlns='http://www.concursolutions.com/api/user/2011/02'><UserProfile><EmpId>E0005</EmpId><FeedRecordNumber>1</FeedRecordNumber><LoginId>myuser1@mycompany.com</LoginId><Password>myP@@sword</Password></UserProfile></Batch>
响应
000000B2 <Error><Message>batch element is missing. Please check your
request.</Message><Server-Time>2016-03-28T19:34:02</Server-Time><Id>XXXXXXXX-AACE-4A49-8EE6-669EF3XXXXX</Id></Error>
00000000
为什么它抱怨“批处理”元素丢失了,但很明显它在内容中?我是否可以参考任何官方文档来获取XML格式来创建用户?
注意:我在这里标记了C#,因为我正在尝试让我的C#代码在这里工作。我编写了代码来生成上面的请求并得到相同的响应。
注意:在参考帖子中,<EmpId>
标记没有关闭。当我第一次尝试时,我发现了一个错误:“请求XML无效。:第1行位置242上的'EmpId‘开始标记与'UserProfile’的结束标记不匹配。第1行,位置328。”因此,我纠正了XML中的错误。然后我将得到批处理元素丢失的错误。因此,我并不完全相信这个XML结构。
发布于 2016-03-29 14:30:05
我从开发者同意书论坛那里得到了答案。问题是,它期望“批处理”元素是区分大小写的。在我提到的XML格式中,这不是唯一的问题。
这是一个用于在V3中添加用户的有效XML,
<batch xmlns="http://www.concursolutions.com/api/user/2011/02"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<UserProfile xmlns="http://www.concursolutions.com/api/user/2011/02" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<FeedRecordNumber>1</FeedRecordNumber>
<Active>Y</Active>
<LoginId>FirstLast@contoso.com</LoginId>
<FirstName>First</FirstName>
<LastName>Last</LastName>
<CtryCode>US</CtryCode>
<LocaleName>en_US</LocaleName>
<CrnKey>USD</CrnKey>
<EmpId>0001</EmpId>
<EmailAddress>FirstLast@contoso.com</EmailAddress>
<Password>password</Password>
<IsTestEmp>N</IsTestEmp>
<ExpenseApprover>Y</ExpenseApprover>
<Custom21>US</Custom21>
<ExpenseUser>Y</ExpenseUser>
<InvoiceApprover>N</InvoiceApprover>
<InvoiceUser>N</InvoiceUser>
<LedgerName>DEFAULT</LedgerName>
<LedgerCode></LedgerCode>
<LocalName>en_US</LocalName>
</UserProfile>
</batch>
https://stackoverflow.com/questions/36273110
复制相似问题