Solved

Notes while adding a ticket via API?

Is it possible to add a note while creating a new ticket via the API?  I tired adding a <notes></notes> block (see below) to my existing POST that creates a new ticket, but it doesn't seem to work.

<notes>
  <helpdesk-note>
     <body_html>
          <body><html><a href="http://linkto.example.com">Link to example.com</a></html></body>
     </body_html>
  </helpdesk-note>
</notes>

Best Answer
Hi Chris

Its not possible to add a note while creating a new Ticket via API, because the Ticket ID field would be needed, to which the note is to be added

If an agent wants to add the comment please use the below xml 

curl -u sample@freshdesk.com:test -H "Content-Type: application/xml" -d "<helpdesk_note><body>Notes From User</body></helpdesk_note>" -X POST http://sample.freshdesk.com/helpdesk/tickets/{ticket-display-id}/notes.xml

 

If you want to add the comment on behalf of the user please use his user_id as below

curl -u sample@freshdesk.com:test -H "Content-Type: application/xml" -d "<helpdesk_note><user_id>52</user_id><body>Notes From User</body></helpdesk_note>" -X POST http://sample.freshdesk.com/helpdesk/tickets/{ticket-display-id}/notes.xml

 

If you want to update a particular note (Note: You need to use body_html attribute in this case)

 

curl -u sample@freshdesk.com:test -H "Content-Type: application/xml" -d "<helpdesk_note><body_html>Dummy duty</body_html></helpdesk_note>" -X PUT http://sample.freshdesk.com/helpdesk/tickets/{ticket-display-id}/notes/{note-id}.xml


regards
Vijay 


Answer
Hi Chris

Its not possible to add a note while creating a new Ticket via API, because the Ticket ID field would be needed, to which the note is to be added

If an agent wants to add the comment please use the below xml 

curl -u sample@freshdesk.com:test -H "Content-Type: application/xml" -d "<helpdesk_note><body>Notes From User</body></helpdesk_note>" -X POST http://sample.freshdesk.com/helpdesk/tickets/{ticket-display-id}/notes.xml

 

If you want to add the comment on behalf of the user please use his user_id as below

curl -u sample@freshdesk.com:test -H "Content-Type: application/xml" -d "<helpdesk_note><user_id>52</user_id><body>Notes From User</body></helpdesk_note>" -X POST http://sample.freshdesk.com/helpdesk/tickets/{ticket-display-id}/notes.xml

 

If you want to update a particular note (Note: You need to use body_html attribute in this case)

 

curl -u sample@freshdesk.com:test -H "Content-Type: application/xml" -d "<helpdesk_note><body_html>Dummy duty</body_html></helpdesk_note>" -X PUT http://sample.freshdesk.com/helpdesk/tickets/{ticket-display-id}/notes/{note-id}.xml


regards
Vijay 

Update : You can view our latest API documentation here : https://developer.freshdesk.com/api/#create_ticket


Cheers!