1
使用的libcurl我最近開始,當我通過命令行卷曲它看起來像這樣和POST正常工作:POSTFIELD應該是什麼樣子?
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"
}
}
}
我應該怎麼寫我POSTFIELDS (-d),因爲這是不正確的:
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "'{""auth"": {""tenantName"": ""admin"", ""passwordCredentials"": {""username"": ""admin"", ""password"": ""openstack""}}}'");