我最近开始使用 libcurl,当我通过命令行 curl 它看起来像这样并且 POST 工作正常:
curl -i -X POST http://192.168.1.128:5000/v2.0/tokens -H "Content-Type: application/json" -H "User-Agent: python-keystoneclient" -d {"auth": {"tenantName": "admin", "passwordCredentials": {"username": "admin", "password": "openstack"}}}
这是 Json 结构:
{
"auth": {
"tenantName": "admin",
"passwordCredentials": {
"username": "admin",
"password": "0002472e1ab140f2"
}
}
}
在通过 C 程序进行卷曲时,我应该如何编写我的 POSTFIELDS (-d),因为这是不正确的:
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "'{""auth"": {""tenantName"": ""admin"", ""passwordCredentials"": {""username"": ""admin"", ""password"": ""openstack""}}}'");