+ Start a Discussion
John DayondonJohn Dayondon 

Calling an external REST API using custom button?

Hi,

I trying to create a custom button on our custom object page that would call an external REST API. 
User-added image

When I tested it it gave me the "Unexpeced end of input" error.
Best Answer chosen by John Dayondon
Navandeep_Kaur23Navandeep_Kaur23
Hi, 
You will need to create a JavaScript button to make an API callout .
Please refer the below links to understand and implement above.

https://developer.salesforce.com/forums/?id=906F00000008sPlIAI
https://developer.salesforce.com/forums/?id=906F0000000991HIAQ

All Answers

John DayondonJohn Dayondon
Just an update, I removed the extra ";" and ")" at the end of that body content but still getting the same error
Navandeep_Kaur23Navandeep_Kaur23
Hi, 
You will need to create a JavaScript button to make an API callout .
Please refer the below links to understand and implement above.

https://developer.salesforce.com/forums/?id=906F00000008sPlIAI
https://developer.salesforce.com/forums/?id=906F0000000991HIAQ
This was selected as the best answer
John DayondonJohn Dayondon
Hi,

Yes, writing a javascript code did solved it. So for those who got into this issue here was how this was solved.

Create an APEX Class to make the external API callout:
User-added image

Call that APEX class from your custom button.
User-added image

Now add this custom button on your page layout and your good.

Note: Add handler for the response object on your APEX code as how you would like it handled.