我使用WooCommerce的Woo REST API v3,并将某些订单从“待处理”更新为“已完成”。
几天以来,我无法使用此方法,因为我收到一条错误消息:
[response:Automattic\WooCommerce\HttpClient\HttpClientException:private] => Automattic\WooCommerce\HttpClient\Response Object
(
[code:Automattic\WooCommerce\HttpClient\Response:private] => 500
[headers:Automattic\WooCommerce\HttpClient\Response:private] => Array
(
[Date] => Fri, 03 May 2019 13:38:40 GMT
[Server] => Apache
[X-Robots-Tag] => noindex
[Link] => ; rel="https://api.w.org/"
[X-Content-Type-Options] => nosniff
[Access-Control-Expose-Headers] => X-WP-Total, X-WP-TotalPages
[Access-Control-Allow-Headers] => Authorization, Content-Type
[Expires] => Wed, 11 Jan 1984 05:00:00 GMT
[Cache-Control] => no-transform, no-cache, must-revalidate, max-age=0
[Set-Cookie] => wfwaf-authcookie-19507c40e0a99b44e590377ed6e2e841=1%7Cadministrator%7C661afdd670ad0705856715deeede671d9a78039a07457b4cf523451dd5158496; expires=Sat, 04-May-2019 01:38:41 GMT; Max-Age=43200; path=/; secure; HttpOnly
[Strict-Transport-Security] => max-age=31556926
[Content-Length] => 0
[Connection] => close
[Content-Type] => application/json; charset=UTF-8
)
[body:Automattic\WooCommerce\HttpClient\Response:private] =>
和
[message:protected] => JSON ERROR: Syntax error
[string:Exception:private] =>
[code:protected] => 500
[file:protected] => /var/www/xxx/html/api/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php
[line:protected] => 378
JSON错误:语法错误 代号:500 身体:
其他任何方法(如get或post)都可以使用,而不会出现JSON错误。我没有编辑产品。
非常感谢您的帮助。
答案 0 :(得分:0)
我通过修复由wordpress生成的关于折旧功能的通知来解决此问题。尝试查看错误日志并修复所有通知/警告。
答案 1 :(得分:0)
我在使用 PUT 方法时遇到了同样的问题,我将它们更改为 POST,现在一切正常
答案 2 :(得分:-1)
在您的woocommerce对象初始化中添加它:
'query_string_auth' => true,
'verify_ssl' => false