簡體   English   中英

使用 Postman 的簡單 Twinfield API 請求

[英]Simple Twinfield API request with Postman

我想將銷售發票與 javascript/google 應用程序腳本連接起來。 因此我想用 Postman 測試一些東西。 我知道,API 與 XML 一起使用並獲取您需要使用所謂的瀏覽代碼 100 的數據。但我堅持創建一個工作請求來獲取銷售發票數據:(

到目前為止我做了什么:

  • 閱讀Twinfield API 文檔
  • 開發者門戶中創建了一個登錄
  • 設法通過 Postman 請求授權碼:我做了一個解決方法來調整 Postman 中的參數,然后將請求 URL 粘貼到瀏覽器中
  • 管理請求訪問令牌
  • 確定集群

我做了很多研究,但找不到任何我能理解的例子。 像這樣的例子

  • Postman 中的請求 URL 應該如何
  • 我需要什么參數
  • 是否有可能在 javascript 中有一個方便的請求來獲取未結銷售發票

如果有任何幫助,我將不勝感激!

嘗試這個

<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>

編輯:讓我們從頭開始,首先我假設您能夠獲得訪問代碼。 使用訪問代碼,您需要對以下 url 執行 Postmand 獲取請求: https://login.twinfield.com/auth/authentication/connect/accesstokenvalidation?token={{Accescode}}

從您需要為我復制 clusterUrl 的結果來看,它看起來像這樣:

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

接下來我們需要找到 companyID,這也是我們可以從 Postman 那里得到的東西,在 url 上發布以下帖子: https ://api.accounting2.twinfield.com/webservices/processxml.asmx?wsdl

如您所見,它具有之前的cluserURL,因此您必須將其替換為您找到的那個。 您需要隨此請求發送的 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>

這將產生一個帶有 ID 的列表,您可以從中收集數據。 要獲取銷售發票,您需要再次使用以下網址:

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

但是這次我們把信封改成我上面貼的第一個,只是整個東西都變成了原始的身體,這應該會產生一張發票清單。

如果您需要更多信息,我可以嘗試收集適合您的收藏,但我希望這足以幫助您入門

編輯2:關於你的第二個問題,你需要設置標題接受xml輸入,見下文標題設置

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM