【问题标题】:Problem with getting the sales price of item in Exact Online在 Exact Online 中获取商品销售价格的问题
【发布时间】:2020-10-14 09:37:33
【问题描述】:

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

但是现在,在我的 Web 应用程序内部,我需要这些帐户和项目等,我完成了选择所有项目并将它们导入我的数据库,但我找不到 SalesPrice一个项目,只有 'CostPriceNew' 和 'CostPriceStandard'!

经过一番搜索,我发现还有一个类叫: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',但我仍然收到错误。

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

【问题讨论】:

  • ps,文档可以在这里找到:start.exactonline.nl/docs/…
  • 引发 http 400 的实际请求的 URL 是什么?
  • @guido 阅读文档;函数 URI /api/v1/{division}/read/logistics/ItemDetailsByID?itemId={Edm.Guid} GET 示例用法 /api/v1/{division}/read/logistics/ItemDetailsByID?itemId=guid'00000000-0000- 0000-0000-000000000000'&$select=代码
  • 发送到 Exact 的实际 URL 是什么?
  • @GuidoLeenders 我试过这个,我不知道这是不是你的意思!,在 get() 函数中我放置了这个代码:var_dump($this->url, $params);,结果我得到了string(48) "read/logistics/ItemDetailsByID?itemId={Edm.Guid}" array(1) { ["Edm.Guid"]=> string(38) "'8afc6734-ae20-4ab2-a44e-403ed41dc9c0'" }

标签: exact-online picqer-exact-php-client


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

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

    记录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"
    }
    

    【讨论】:

      猜你喜欢
      • 2021-05-18
      • 2021-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-24
      相关资源
      最近更新 更多