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.

3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.