1

我正在尝试使用准确的在线 API,我的 Web 应用程序可以与 API 连接并创建帐户、项目和所有其他内容。

但是现在,在我的网络应用程序内部,我需要那些帐户和项目等,我完成了选择所有项目并将它们导入我的数据库,但我找不到项目的销售价格,只有“成本价格新”和'成本价格标准'!

经过一段时间的搜索,我发现在这个类里面还有另一个类叫做:ItemDetailsByID我找到了SalesPrice

起初我得到一个错误:Fatal error: Uncaught TypeError: Argument 1 passed to Picqer\Financials\Exact\ItemDetailsByID::get() must be of the type array, string given

这是我使用的代码:`

//Retrieve items
$items = new \Picqer\Financials\Exact\Item($connection);
$result = $items->get();

foreach ($result as $item) {

    try {

        $ItemDetails = new \Picqer\Financials\Exact\ItemDetailsByID($connection);
        $result1 = $ItemDetails->get($item->ID);

        foreach ($result1 as $ItemDetail) {

            var_dump($ItemDetail);

        }
        
    } catch (\Exception $e) {

        echo json_encode(array(get_class($e) . ' : ' . $e->getMessage()));

    }

}

`

从确切的在线阅读文档后,我仍然无法使用此类..现在我收到此错误:["Picqer\\Financials\\Exact\\ApiException : Error 400: Bad Request - Error in query syntax."]

在第一个错误之后我改变了我的代码$result1 = $ItemDetails->get($item->ID);

进入

$result1 = $ItemDetails->get(["eq guid" => "'$item->ID'"]);

我尝试了多个数组键,例如:'eq guid'、'Edm.Guid'、'guid'、'id',但我仍然收到错误消息。

我希望有人可以帮助我或指出我正确的方向。

4

2 回答 2

1

您不想列出所有商品的价格,因此您应该使用 find 而不是使用 get。由于您只得到一个结果,之后您可以直接使用返回的对象:

$ItemDetails = new \Picqer\Financials\Exact\ItemDetailsByID($connection);
$result1 = $ItemDetails->find($item->ID);
var_dump($result1->SalesPrice);
于 2021-07-19T19:28:06.510 回答
0

您的问题不是很清楚,在您添加更多信息之前,我会尝试给您一个一般性建议。

记录http协议并与文档比较,如果没有客户端日志,可以将请求发送到httpbin.org(注意密码和其他使用第三方服务的个人盗版),就像https:// httpbin.org/get?itemId=guid'00000000-0000-0000-0000-000000000000'&$select=Code,SalesCurrency,SalesPrice

它将打印请求信息,这有助于调试

{
    "args": {
        "$select": "Code,SalesCurrency,SalesPrice",
        "itemId": "guid'00000000-0000-0000-0000-000000000000'"
    },
    "headers": {
        "Accept": "*/*",
        "Accept-Encoding": "gzip, deflate, br",
        "Cache-Control": "no-cache",
        "Host": "httpbin.org",
        "User-Agent": "PostmanRuntime/7.26.5",
    },
    "origin": "a.b.c.d",
    "url": "https://httpbin.org/get?itemId=guid'00000000-0000-0000-0000-000000000000'&$select=Code,SalesCurrency,SalesPrice"
}
于 2020-10-17T07:09:39.403 回答