cannot add user through curl via api

iotologist8 years ago
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, "http:<url>:8082/api/users");
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_HEADER, 0);
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, '{"name": "test3","email":"test3@asdf.com","password": "test3"}');
      $response=curl_exec($ch);
      curl_close($ch);

please help, what did I do wrong?

:(

Anton Tananaev8 years ago

How do you do authorization?

iotologist8 years ago

Sorry, just forgot to add this

      $headers = array();
      $headers[] = "Content-Type: application/json";
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

all good now :)

Thanks @Anton