简体   繁体   English

使用 Postman 的简单 Twinfield API 请求

[英]Simple Twinfield API request with Postman

I want to connect sales invoices with javascript/ google apps script.我想将销售发票与 javascript/google 应用程序脚本连接起来。 Therefore I want to test some things with Postman.因此我想用 Postman 测试一些东西。 I know, that the API works with XML and to get data you need to use the so called Browse code 100. But I am stucked with creating a working request to get sales invoice data :(我知道,API 与 XML 一起使用并获取您需要使用所谓的浏览代码 100 的数据。但我坚持创建一个工作请求来获取销售发票数据:(

What I did so far:到目前为止我做了什么:

  • Read the Twinfield API documentation阅读Twinfield API 文档
  • Created a login in the developer portal开发者门户中创建了一个登录
  • Managed to request authorization code with Postman: I did a workaround to adjust the parameters in Postman and then paste the request URL into the browser设法通过 Postman 请求授权码:我做了一个解决方法来调整 Postman 中的参数,然后将请求 URL 粘贴到浏览器中
  • Managed to request access token管理请求访问令牌
  • Determine cluster确定集群

I did a lot of research but couldn't find any examples I could understand.我做了很多研究,但找不到任何我能理解的例子。 Examples like像这样的例子

  • how should a request URL in Postman look like Postman 中的请求 URL 应该如何
  • what parameters do I need我需要什么参数
  • is it possible to have a handy request in javascript to get open sales invoices是否有可能在 javascript 中有一个方便的请求来获取未结销售发票

I would be very grateful for any help!如果有任何帮助,我将不胜感激!

Try this尝试这个

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Header>
        <Header xmlns="http://www.twinfield.com/">
            <AccessToken>{{Accescode}}</AccessToken>
            <CompanyCode>{{Company}}</CompanyCode>
        </Header>
    </soap:Header>
    <soap:Body>
        <ProcessXmlDocument xmlns="http://www.twinfield.com/">
            <xmlRequest>
                <columns code="100">
                    <column xmlns="">
                        <field>fin.trs.head.yearperiod</field>
                        <operator>between</operator>
                        <from>2021/01</from>
                        <to>2022/01</to>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.head.code</field>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.head.shortname</field>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.head.number</field>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.head.status</field>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.head.date</field>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.line.dim2</field>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.line.dim2name</field>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.head.curcode</field>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.line.valuesigned</field>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.line.basevaluesigned</field>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.line.repvaluesigned</field>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.line.openbasevaluesigned</field>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.line.invnumber</field>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.line.datedue</field>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.line.matchstatus</field>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.line.matchnumber</field>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.line.matchdate</field>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.line.openvaluesigned</field>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.line.availableforpayruns</field>
                        <visible>true</visible>
                    </column>
                    <column xmlns="">
                        <field>fin.trs.line.modified</field>
                        <visible>true</visible>
                    </column>
                </columns>
            </xmlRequest>
        </ProcessXmlDocument>
    </soap:Body>
</soap:Envelope>

EDIT: Lets start with the beginning, first I'm assuming you are able to get the access code.编辑:让我们从头开始,首先我假设您能够获得访问代码。 With the access code you need to do a Postmand get request to the following url: https://login.twinfield.com/auth/authentication/connect/accesstokenvalidation?token={{Accescode}}使用访问代码,您需要对以下 url 执行 Postmand 获取请求: https://login.twinfield.com/auth/authentication/connect/accesstokenvalidation?token={{Accescode}}

from the results you need to copy over the clusterUrl for me it looks like this:从您需要为我复制 clusterUrl 的结果来看,它看起来像这样:

"twf.clusterUrl": "https://api.accounting2.twinfield.com"

Next we need to find the companyID's this is also something we can get from Postman with the following post to the url: https://api.accounting2.twinfield.com/webservices/processxml.asmx?wsdl接下来我们需要找到 companyID,这也是我们可以从 Postman 那里得到的东西,在 url 上发布以下帖子: https ://api.accounting2.twinfield.com/webservices/processxml.asmx?wsdl

as you can see this has the cluserURL from before so you've to replace this with the one you find.如您所见,它具有之前的cluserURL,因此您必须将其替换为您找到的那个。 The XML envelope you need to send with this request is the following:您需要随此请求发送的 XML 信封如下:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:twin="http://www.twinfield.com/">
    <soapenv:Header>
        <twin:Header>
            <twin:AccessToken>{{Accescode}}</twin:AccessToken>
        </twin:Header>
    </soapenv:Header>
    <soapenv:Body>
        <twin:ProcessXmlString>
            <twin:xmlRequest><![CDATA[<list><type>offices</type></list>]]></twin:xmlRequest>
        </twin:ProcessXmlString>
    </soapenv:Body>
</soapenv:Envelope>

this will result in a list with ID's you can collect the data from.这将产生一个带有 ID 的列表,您可以从中收集数据。 To get the sales invoices you need to use the following url again:要获取销售发票,您需要再次使用以下网址:

https://api.accounting2.twinfield.com/webservices/processxml.asmx?wsdl https://api.accounting2.twinfield.com/webservices/processxml.asmx?wsdl

but this time we change the envelope to the first one I posted above, just the whole thing into the raw body, this should result in a list of invoices.但是这次我们把信封改成我上面贴的第一个,只是整个东西都变成了原始的身体,这应该会产生一张发票清单。

if you need more info I can try to get a collection working for you but I hope this will help enough to get you started如果您需要更多信息,我可以尝试收集适合您的收藏,但我希望这足以帮助您入门

Edit 2: Regarding your second question, you need to set the header to accept the xml input, see below编辑2:关于你的第二个问题,你需要设置标题接受xml输入,见下文标题设置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM