PHP Classes

Salesforce Add New Account

Recommend this page to a friend!

      PHP OAuth Library  >  All threads  >  Salesforce Add New Account  >  (Un) Subscribe thread alerts  
Subject:Salesforce Add New Account
Summary:Feeling silly because your code always works...
Messages:3
Author:Shelly Warren
Date:2016-05-22 18:28:34
 

  1. Salesforce Add New Account   Reply   Report abuse  
Picture of Shelly Warren Shelly Warren - 2016-05-22 18:28:34

Hello again,
First, thank you for your help, you are amazing and your code always works so I am pretty sure I missed something...

Please help me, I need to create new accounts in Salesforce and I believe all I needed to do was change the call a little but I am getting this error:
"Error: it was not possible to open the API call URL: it was not specified the protocol type argument" and "MediaType of 'application/x-www-form-urlencoded' is not supported by this resource"

The call:
$success = $this->sfConnObj->CallAPI(
$this->sfConnObj->access_token_response['instance_url']."/services/data/v20.0/sobjects/Account/",
'POST', array("Name"=>"FROGMAN TEST"),
array('FailOnAccessError'=>true,'FollowRedirection'=>true), $test);


I do get a connection and can pull data so I believe the tokens and auth are correct.

  2. Re: Salesforce Add New Account   Reply   Report abuse  
Picture of Shelly Warren Shelly Warren - 2016-05-22 19:04:17 - In reply to message 1 from Shelly Warren
It was me....

I needed to change the call a little, needed to use the RequestContentType/ResponseContentType options:

$success = $this->sfConnObj->CallAPI(
$this->sfConnObj->access_token_response['instance_url']."/services/data/v20.0/sobjects/Account/",
'POST', array("Name"=>"FROGMAN TEST"), array(
'FailOnAccessError'=>true,
'FollowRedirection'=>true,
'RequestContentType'=>'application/json',
'ResponseContentType'=>'application/json'
), $test);

Thanks!!

  3. Re: Salesforce Add New Account   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2016-05-22 20:14:14 - In reply to message 2 from Shelly Warren
Ok, good to know that you figured it out.