2013-10-22 72 views
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""}}}'"); 

回答

0

您需要引用字符串中的每個雙引號作爲\「。

重新運行您的命令行並在命令後附加「--libcurl example.c」,您將獲得一個良好的胚胎。

相關問題