1 Reply Latest reply on Dec 6, 2016 1:32 PM by Kenny Elkington

    Adding Lead to Program via REST API - getting 605 error: Request method 'POST' not supported"

      I am trying to create and add lead to a program as a member. I can create the lead, but cannot add it to a program.

       

      URL I am using:

      $program_url = $this->host . "/rest/v1/leads/programs/" . $programId (defined) . "/status.json?access_token=" . $token(defined);

       

      Results I am echoing:

      Program request body: {"status":"new status","lookupField":"id","input":[{"id":1532589}]}

      Program request response: {"requestId":"f108#15863ca68a7","success":false,"errors":[{"code":"605","message":"Request method 'POST' not supported"}]}

       

       

      This is my code for reference:

       

        $program_url = $this->host . "/rest/v1/leads/programs/" . $programId . "/status.json?access_token=" . $token;

        $lead = new stdClass();

        $lead->id = $lead_id;

        $body = new stdClass();

        $body->status = 'new status';

        $body->lookupField = 'id';

        $body->input = array($lead);

        $program_requestBody = json_encode($body);

        $program_ch = curl_init($program_url);

        curl_setopt($program_ch,  CURLOPT_RETURNTRANSFER, 1);

        curl_setopt($program_ch, CURLOPT_HTTPHEADER, array('accept: application/json','Content-Type: application/json'));

        curl_setopt($program_ch, CURLOPT_POST, 1);

        curl_setopt($program_ch, CURLOPT_POSTFIELDS, $program_requestBody);

        curl_getinfo($program_ch);

        $program_response = curl_exec($program_ch);

       

      Please help,

       

      Thank you

       

      Sara

       

      Message was edited by: Sara Chaparro