首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为JSONString Zoho inventory api传递的值无效

为JSONString Zoho inventory api传递的值无效
EN

Stack Overflow用户
提问于 2019-09-11 07:19:09
回答 2查看 688关注 0票数 0

我正在尝试使用zoho inventory api并将其示例curl代码转换为在php中使用。

代码语言:javascript
复制
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://inventory.zoho.com/api/v1/salesorders");

$vars = array(
    "authtoken" => "",
    "organization_id" => "",
    "JSONString" => '{
        "customer_id": 4815000000044080,
    }'
);

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$vars);  //Post Fields
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$headers = [
    'Authorization: Zoho-authtoken ',
    'Content-Type: application/json;charset=UTF-8',
];

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$server_output = curl_exec ($ch);

echo $server_output;

curl_close ($ch);

在页面上,我得到了这样的响应

{"code":4,"message":"Invalid value passed for JSONString"}

文档中的原始代码是

代码语言:javascript
复制
$ curl https://inventory.zoho.com/api/v1/salesorders?authtoken=ba4604e8e433g9c892e360d53463oec5&organization_id=10234695
-X POST
-H "Authorization: Zoho-authtoken ba4604e8e433g9c892e360d53463oec5"
-H "Content-Type: application/json;charset=UTF-8"
-d JSONString='{
    "customer_id": 4815000000044080,
}'

我尝试了各种谷歌搜索,似乎很多人都有同样的问题,但还没有给出答案。

我认为我试图以错误的方式添加JSONString

在php中使用curl发送JSONString的正确方式是什么?

EN

回答 2

Stack Overflow用户

发布于 2019-09-29 14:12:50

下面的代码不会给出“{”c#“:4,”message“:”“value passed for JSONString"}”错误。

https://i.stack.imgur.com/vDRRE.png

如果你有任何类型的问题,请发邮件给我。"shiva151316@gmail.com“

票数 0
EN

Stack Overflow用户

发布于 2020-04-30 01:42:30

我使用servise http://httpbin.org/post来查看我的post查询是如何查找zoho的。并在JSONString编码之前找到错误的符号,这是BOM编码。所以,我改变了编码,这样就可以了。

Look Example

票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57879271

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档