【问题标题】:Postman and Guzzle giving a different number of resultsPostman 和 Guzzle 给出不同数量的结果
【发布时间】:2021-06-22 00:56:10
【问题描述】:

当我在 Postman 中测试 POST 请求时,可以在其中看到 167 个结果

使用 Guzzle,只能看到 100

$data = Http::post(url, [...]);

$data_decoded = json_decode($data);

dd($data_decoded);

如何获得全部 167 个?

【问题讨论】:

  • 看这里:docs.guzzlephp.org/en/stable/request-options.html#expect 它似乎默认限制为 100。如果我理解,您可以更改有效负载大小。
  • 你完全确定objectId 每个数组项存在一次吗?是否有可能在您的数组项的嵌套条目中也发现了它?之所以提到这一点,是因为您比较在 Guzzle 中找到的条目和在 Postman 中找到的属性。
  • @Tschitsch 是的,我确定。正如@Hamham 最初建议的那样,在参数中添加limit:5000 解决了问题
  • @Hamham 欢迎你写答案
  • 完成了:),很高兴它会有所帮助。

标签: php laravel post postman guzzle


【解决方案1】:

你可以read here

默认情况下,当请求正文的大小大于 1 MB 并且请求使用 HTTP/1.1 时,Guzzle 将添加“Expect: 100-Continue”标头。

您可以更改有效负载大小。例如,如果你有这种可能性,只需传递一个limit 参数,如

$data = Http::post(url, [..., 'limit'=>300]);

$data_decoded = json_decode($data);

dd($data_decoded);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-19
    • 2012-07-12
    • 2021-09-25
    • 2023-03-30
    • 1970-01-01
    • 2011-04-03
    • 2015-08-26
    相关资源
    最近更新 更多