3

I'm new with ExactTarget APIs, I'm using Php curl to request the ExactTarget REST API.

Basically, I tried to create a contact:

 $array = array(
    'contactKey' => '[email protected]',
    'contactId' => null,
    'attributeSets' =>  array(
        'name' => 'Email Addresses',
        'items' => array('values' => array('name' => 'Email Address', 'value' => '[email protected]'))
    ),
  );
  $postfield = json_encode($array);
  var_dump(json_decode($postfield));
  $curl = curl_init( "https://www.exacttargetapis.com/contacts/v1/contact" );
  curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $accessToken ) );
  curl_setopt( $curl, CURLOPT_POST, true );
  curl_setopt( $curl, CURLOPT_POSTFIELDS,  $postfield );
  curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, FALSE);
  curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1);

But this fall in a 404 error:

 object(stdClass)[2]
  public 'documentation' => string 'https://code.docs.exacttarget.com/rest/errors/404' (length=49)
  public 'errorcode' => int 404
  public 'message' => string 'Not Found' (length=9)

Could you please help me ? What am I doing wrong ? I tried to change my $array, even with an empty array I always get this message.


Otherwise, I tried to create a campaign the same way:

$array = array(
      'name' => 'Testapi',
      'description' => 'description try',
      'campaignCode' => 'ooiampaign',
      'color' => '0000ff',
      'favorite' => false
      );
  $postfield = json_encode($array);
  $curl = curl_init( "https://www.exacttargetapis.com/hub/v1/campaigns" );
  curl_setopt( $curl, CURLOPT_HTTPHEADER, array( 'Authorization: Bearer ' . $accessToken ) );
  curl_setopt( $curl, CURLOPT_POST, true );
  curl_setopt( $curl, CURLOPT_POSTFIELDS,  $postfield );
  curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, FALSE); // important (testé en Local wamp) afin de ne pas vérifier le certificat SSL
  curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1);

I got a successful result but the name, the campaignCode and the description are empty in the campaign created.

If someone could help me with those 2 issues, that would be really great.

Thank you, and sorry if I misspelled something, English is not my native language.

3
  • I'm seeing the same issue. Did you ever solve the 404 problem with /contacts?
    – Ray
    Nov 19, 2014 at 21:43
  • BTW: I've also tried the plural version url https://www.exacttargetapis.com/contacts/v1/contacts
    – Ray
    Nov 19, 2014 at 21:45
  • No, not yet. If I do, I'll let you know here. Nov 21, 2014 at 7:37

1 Answer 1

1

I spoke with the Salesforce support team. The REST /contacts endpoint is not a direct replacement for the SOAP API's functionality to add and modify Subscibers to lists. Currently the REST API does not support this. The contacts if for other salesforce functionality that if you don't have enabled (you're just using ET for example) will 404. So, to work with Subscribers you must use the ET SOAP api.

ET has created a set of SDKs which abstracts and combines both the REST and the SOAP API functionality--available in several languages such as java, ruby, php. https://code.exacttarget.com/apis-sdks/fuel-sdks/

Yup this is crazy. Yup it smells of entropy.

I think it's directly tied to the challenges they're having absorbing ET into Salesforce why so long after the merger they don't have a cohesive single API solution.

3
  • Oh, ok. Thank you for your this update Ray. Otherwise, do you have some informations about the /campaigns endpoint ? why am I able to create campaigns but only empty ones (name, description etc. sent but not handled by ET) ?! Nov 25, 2014 at 7:42
  • @DevCRMconsult No, not familiar with the campaigns endpoint. I think the reasons the two endpoints are failing are unrelated. I'd suggest making the two issues separate questions.
    – Ray
    Nov 25, 2014 at 14:42
  • Hum ok, will check if I can contact the SF support team this week and I will post something here if I get more info. Nov 25, 2014 at 14:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .