Use webhooks to update custom company field

  • 7 August 2018
  • 4 replies
  • 253 views

Hi, 


I am trying to set up an observer rule where when we have a ticket with the subject "launch date" it automatically updates the custom "Launch Date" field of the associated company to the creation date of the ticket. I am a bit stuck on how to post to that field using webhooks. 


My callback URL is https://org.freshdesk.com/api/v2/companies{{ticket.company.launch_date}}


and my (sample) content is 


POST

{

 "custom_fields" : { "launch_date": "1/1/2018"} 

}


Where I am stuck is how to get the date the ticket was created and post it to the company's launch date. 


Any help would be greatly appreciated! 



This topic has been closed for comments

4 replies

Userlevel 4
Badge +12

Hello Eli,


If the ticket subject carries the launch date, you could use the Dispatchr' webhook as it would act immediately on ticket creation. 


You could use liquid filters to strip off the content from the subject, using the placeholder {{ticket.subject}}, leaving behind the launch date alone. 


The callback URL has to be constructed in a way that the endpoint is actually the company profile - https://org.freshdesk.com/api/v2/companies/{{ticket.company.id}}


Hope this helps!


Cheers!

Thanks for the help! 


I'm still not clear on how I can put this into my custom field though


Userlevel 4
Badge +12

Eli,


Maybe see if this can make it easier :)


Content type - Application/Json

Request type - PUT

Endpoint - https://domain.freshdesk.com/api/v2/companies/{{ticket.company.id}}

Sample request:


{

"custom_fields":{"launch_date":"{{ticket.subject}}"};

}


Cheers!

Thank you, that clears a lot up. 


However, it's the company still isn't getting updated. 


I have attached a screenshot of what I'm trying to do. Note that I am not actually using https://domain.freshdesk.com/api/v2/companies/{{ticket.company.id}} as my end point, I just changed it because I'm uploading this to a forum. I am using our correct domain when I try to make the request. 





api_34787.png