1

I have recently starting using libcurl, when I curl via command line it looks like this and POST works fine:

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"}}}

This is the Json structure:

{
"auth": {
    "tenantName": "admin", 
    "passwordCredentials": {
        "username": "admin", 
        "password": "0002472e1ab140f2" 
    }
}
}

How should I write my POSTFIELDS (-d) while curling through a C program because this is incorrect:

curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "'{""auth"": {""tenantName"": ""admin"",   ""passwordCredentials"": {""username"": ""admin"", ""password"": ""openstack""}}}'");
mobykhn
  • 221
  • 1
  • 4
  • 14

1 Answers1

0

You need to quote each double-quote within the string as \".

Rerun your command line and append "--libcurl example.c" to the command and you'll get a good embryo to start from.

Daniel Stenberg
  • 54,736
  • 17
  • 146
  • 222