AnsweredAssumed Answered

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

Question asked by dd37cfe2576e41a81ae31c363b7da5566f058f60 on Dec 5, 2016
Latest reply on Dec 6, 2016 by 2dd6bfd88d69f25c6fc247c59fc5eb9ce38b8164

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);


  $program_response = curl_exec($program_ch);


Please help,


Thank you




Message was edited by: Sara Chaparro