Jump to content


Photo

How to add a comment via the API ?

API

  • Please log in to reply
2 replies to this topic

#1 glebret

glebret

    Advanced Member

  • Members
  • PipPipPip
  • 51 posts
  • LocationToulouse - France

Posted 03 October 2017 - 12:55 PM

Hi,

 

I'm trying to add a comment via my API.

 

I can connect with my API, search for a contact, but I didn't find (I think I red all internet and the X2 docs) HOW to add a comment to this contact.

 

Any hint will be a huge help for me.

 

Thanks.

 

NB : I connect to my x2engine with an API made on google apps script, If you want the code, just ask me.



#2 X2Isaiah

X2Isaiah

    Advanced Member

  • Moderators
  • 117 posts

Posted 03 October 2017 - 01:01 PM

Hey glebret,

 

Comments on a contact are actually just actions linked with activity feed events that are associated with the contact, I would check those two tables in your x2 database (x2_action_to_record, x2_events) for more information



#3 glebret

glebret

    Advanced Member

  • Members
  • PipPipPip
  • 51 posts
  • LocationToulouse - France

Posted 03 October 2017 - 01:24 PM

Thanks !

 

I finally find how to do it : here is the code (in Google Apps Script) :

 

messages_url = "http://MYDOMAIN/inde...Contacts/ID(999for example)/Actions";
  
  var payload = {
    "type" : "note",
    "associationId" : 999,
    "associationType" : "contacts",
    "actionDescription" : "Note inscrite par API"
  };
  options = {
    "method" : "post",
    "contentType" : "application/json",
    "muteHttpExceptions": true,
    "payload" : JSON.stringify(payload)
  };
 
  options.headers = { 
    "Authorization" : "Basic " + Utilities.base64Encode("USERNAME:API_KEY_OF_THE_USER_NAME"),
    "charset" : "utf-8"
  };
 
  reponse = UrlFetchApp.fetch(messages_url, options);






Also tagged with one or more of these keywords: API

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users