MoneyWorks:以编程方式更新记录


MoneyWorks: Programmatically update a record

我想更新MoneyWorks中的记录。我可以使用 REST API 创建,但我没有找到更新记录的帮助。

我正在使用此文档 http://cognito.co.nz/developer/moneyworks-datacentre-rest-api/

使用以下代码创建记录 im 并且它正在工作

<?php
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://server/REST/username:password@doc/import/table=name&format=xml-verbose");
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
    $result = curl_exec($ch);
    curl_close($ch);
?>

其中$xml是字符串中的输入 XML。在文档中,他们提到我们可以更新记录,但他们没有提供示例。

请帮助我使用 REST API 更新记录

首先,您不要在 URL 中指定表名称和格式(您可以将它们用于导出,这是一个GET)。表名和其他导入参数在 xml 中指定为表元素的属性。要更新记录,请指定update="true" 。请参阅此处的文档 http://cognito.co.nz/developer/xml-data-exchange/

例如,您可以导入以下 xml 来更新 SPRING 名称记录的一个字段。您可以通过复制xml并将其粘贴到MoneyWorks中的任何列表窗口中(在MoneyWorks Gold 7.1.8及更高版本中调用XML导入)来测试这一点。相同的 XML 将适用于 REST 导入。

<?xml version="1.0"?>
<table name="Name" update="true">
    <name>
        <code>SPRING</code>
        <contact>New contact name</contact>
    </name>
</table>