1

I'm trying to call a .NET api controller from php

  $user = $ctl->getUser();
        $client = $ctl->getCurrentClient();
        $userid = $user->getID();
        $clientid = $client->getID();
        $data = array('userid' => $userid, 'clientid' => $clientid);

        $data_string = json_encode($data);           


          $ch = curl_init('https://localhost:44346/api/participantapi/TransferParticipants');

          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',
            'Content-Length: ' . strlen($data_string))                   
        );          

        $result = curl_exec($ch);

        print_r($result);
        curl_close($ch);

My controller looks like

    [HttpPost]
    [Route("TransferParticipants")]
    public IActionResult TransferParticipants(JObject data)

If I make the call from postman it works fine. But when I make this call from the php code, I don't see anything. Is there anyway for me to see what I'm missing. Any help would be much appreciated.

I tried the options from that post and still no luck. It seems like it isn't sending at all.

brachen33
  • 117
  • 2
  • 10
  • You might see if [curl_error()](http://php.net/manual/en/function.curl-error.php) gives you anything. – Patrick Q Aug 20 '18 at 20:33
  • That is showing an SSL error. 'SSL certificate problem: unable to get local issuer certificate' Is there anyway to get around that? – brachen33 Aug 20 '18 at 20:38
  • Possible duplicate of [PHP - SSL certificate error: unable to get local issuer certificate](https://stackoverflow.com/questions/28858351/php-ssl-certificate-error-unable-to-get-local-issuer-certificate) – Patrick Q Aug 20 '18 at 20:39

0 Answers0