dependent variables are:
$randomString which is random string
$num_rows[0] which is correct access_token after oAuth 2.0 process
Requet :
$params = array(
"kind" => "compute#disk",
"zone" => "https://www.googleapis.com/compute/v1/projects/plenary-ability-439/zones/us-central1-a",
"name" => $randomString,
"description" => "any description "
);
$ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER,0); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); $headers = array("Content-Type: application/json" ); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $result = curl_exec($ch); $res = json_decode($result, true);Respnse :
{
"error": {
"errors": [
{
"domain": "global", "reason": "parseError", "message": "This API does not support parsing form-encoded input."}
],
"code": 400,
"message": "This API does not support parsing form-encoded input."
}
}
$headers = array("Content-Type: application/json" ); is onething i come know so far and i have set this correctly
*second things is : i also tried this but i got same response *
$headers = array(
"Content-Type: application/json",
"Authorization: Bearer $num_rows[0]",
);