【问题标题】:Acumatica Using $filter programmatically gives HTTP 400 Bad requestAcumatica 使用 $filter 以编程方式给出 HTTP 400 错误请求
【发布时间】:2023-04-02 03:42:01
【问题描述】:

我在我的 php 代码中使用这个 url

https://awesomedomain.app/entity/Default/18.200.001/SalesOrder?$filter=Status eq 'Completed'

像这样:

$acumaticaOrder = $this->Acumatica_API("/entity/Default/18.200.001/SalesOrder?$" . 'filter' . "=Status eq 'Completed'", 'GET');

但它给出了“Bad request”错误

然而,我在 Postman 中使用相同的链接,但它给了我那些标记为已完成的订单。

我什至检查了我正在制作的 URL,并将相同的 URL 复制粘贴到 Postman 中,在 Postman 中它可以工作。但它以编程方式给出 HTTP 400 错误请求。

【问题讨论】:

  • 你为什么要连接“过滤器”?
  • 我想我没听懂你的意思。我正在连接“过滤器”,因为我想使用它。我将它单独连接起来,因为在 API 中,“过滤器”应该与美元符号一起使用,如 $filter=Status eq 'Completed' 和 'Completed' 单引号会起作用。所以我必须将整个字符串包裹在双引号中。双引号导致 $filter 被表示为 PHP 变量。这就是我以这种方式连接的原因。
  • @PatrickChen 我什至试过这样,但它仍然说请求错误 $acumaticaOrder = $this->Acumatica_API('/entity/Default/18.200.001/SalesOrder?$filter=Status eq ' 。" '完成'", 'GET');
  • 其他查询参数,例如 $expand,似乎没有任何问题

标签: php acumatica


【解决方案1】:

你的字符串应该是这样的结构:

$url = 'http://localhost/Acumatica20R2DB/entity/Default/20.200.001/SalesOrder?$filter=Status%20eq%20%27Completed%27';

单引号会让 PHP 忽略你的 $ 并且你需要在你的过滤器中对空格和 's 使用 html 编码。

【讨论】:

    猜你喜欢
    • 2014-08-18
    • 1970-01-01
    • 1970-01-01
    • 2014-06-22
    • 1970-01-01
    • 2013-09-12
    • 2017-07-21
    • 1970-01-01
    • 2016-11-18
    相关资源
    最近更新 更多