title: How to create the REST API for this curl operation in PHP
body: <p>I want executed this simple curl operation through php how can i execute this in simple php not any framework , can i do it in simple php or do i need the framework? </p>
  
  <pre><code>curl -XPOST localhost:12060/repository/schema/fieldType -H 'Content-Type: application/json' -d '
  {
    action: "create",
    fieldType: {
      name: "n$name",
      valueType: { primitive: "STRING" },
      scope: "versioned",
      namespaces: { "my.demo": "n" }
    }
  }' -D -
  </code></pre>
  
  <p>what i tried is :</p>
  
  <pre><code>&lt;?php
  $url="localhost:12060/repository/schema/fieldType";     
  //open connection
  $options = array(
  CURLOPT_RETURNTRANSFER =&gt; true, // return web page
  CURLOPT_HEADER =&gt; false, // don't return headers
  CURLOPT_FOLLOWLOCATION =&gt; true, // follow redirects
  CURLOPT_ENCODING =&gt; "", // handle all encodings
  CURLOPT_USERAGENT =&gt; "spider", // who am i
  CURLOPT_AUTOREFERER =&gt; true, // set referer on redirect
  CURLOPT_CONNECTTIMEOUT =&gt; 120, // timeout on connect
  CURLOPT_TIMEOUT =&gt; 120, // timeout on response
  CURLOPT_MAXREDIRS =&gt; 10, // stop after 10 redirects
  );
  $ch = curl_init();
  
  //set the url, number of POST vars, POST data
  curl_setopt($ch,CURLOPT_URL,$url);
  $fieldString=array(
      "action"=&gt; "create",
      "fieldType"=&gt;array(
          "name"=&gt; "n$name",
          "valueType"=&gt; array( "primitive"=&gt; "STRING" ),
          "scope"=&gt; "versioned",
          "namespaces"=&gt; array( "my.demo"=&gt; "n" )
      )
  );
  //for some diff
  curl_setopt($ch, CURLOPT_HTTPHEADERS, array('Content-Type: application/json'));
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode("{json: $fieldString}"));
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt_array( $ch, $options );
  //execute post
  $result = curl_exec($ch);
  $header = curl_getinfo( $ch );
  echo $result;
  //close connection
  curl_close($ch);
  
  
  
  
  ?&gt;
  </code></pre>
  
  <p>But it is giving me this </p>
  
  <pre><code>The given resource variant is not supported.Please use one of the following: * Variant[mediaType=application/json, language=null, encoding=null] 
  </code></pre>