windows中使用curl命令需要下载curl工具
下载地址:http://curl.haxx.se/download.html
请选择不带SSL的版本,否则还需要安装SSL的支持包
我下载的版本 http://www.paehl.com/open_source/?CURL_7.28.1
下载后解压,将exe文件拷贝到 C:\windows\system32目录下即可在cmd中直接调用
我使用linux下成功的相同命令去发现报错如下:
{"error_description":"Invalid client authentication","error":"invalid_client"}
网上查发现是引号的原因,
例如linux下成功命令格式如下:
curl -s -request POST --url https://api.dataflow.iot.att.com/v1/oauth2/token --header "content-type: application/json" --data '{"client_id":"902fbc20-be05-11e9-bfbb-758f72724394","client_secret":"7vCmZ8RDDyWQbGeXurACt36b6eg70fNT"}'
windows下就应该如下:
curl -s -request POST --url https://api.dataflow.iot.att.com/v1/oauth2/token --header "content-type: application/json" --data "{\"client_id\":\"902fbc20-be05-11e9-bfbb-758f72724394\",\"client_secret\":\"7vCmZ8RDDyWQbGeXurACt36b6eg70fNT\"}"
综上所述:在window中,在-d 数据中属性需要在引号上加斜杠进行转义\”,而且在-d 数据中{} 最外面用双引号
在linux中,不需要斜杠转义,在-d 数据中{} 最外面用单引号