0

I am trying to write the php script to run curl job and here is the curl query to create the ticket

     curl -X POST -H "Content-Type: application/json" -H
    "username:username" -H "password:password" --data
   '{"serviceName":"CREATE_AVENT","keyValues":{"title":
    "test","actionableevent_priority": "Minor","source":
    "TEC","requester_login": "user"}}' -k
   https://createticket.com/arsys/rest/service/createTicket

Here is the script I wrote in php

$url="https://createticket.com/arsys/rest/service/createTicket";
$field=array("serviceName"=>"CREATE_AVENT","keyValues"=>array("title"=>"test","actionableevent_priority"=>"Minor","source"=>"TEC","requester_login"=>"user"));
$data_string = json_encode($field);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_CAINFO, "/var/www/xxx/cacert.pem");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json','username:username','password:password'));

$output = curl_exec($ch);
print_r($output);
$info = curl_getinfo($ch);
$err=curl_error($ch);
print_r($err);
print "\n";
curl_close($ch);

When I execute the curl query it returns ticket ID and creates a ticket in the system. However when I run the script it is not returning anything as well as no ticket in the system. Can anybody tell me what is wrong with this script?

SooIn Nam
  • 3,121
  • 4
  • 21
  • 18

1 Answers1

0

From comment, I read php code failed to verify server certificate. This is option to ignore certificate if you're ok to do so.

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

I found more detailed configuration in this question.

Community
  • 1
  • 1
suztomo
  • 5,114
  • 2
  • 20
  • 21