function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bujjibujji 

Run CURL from APEX class

Hi Guys,

Is there any way that i can run cURL commands in apex call to connect third party systems. Because i am getting some SSL certificate error when i try to connect the third party system but from cURL i am able to connect. Please give me some idea URGENT.

Thanks!
Martijn SchwarzerMartijn Schwarzer
Hi bujji,

Unfortunately, you cannot run cUrl from Apex. It's an open source tool. See also the following page:

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_curl.htm

It states that cUrl is not supported by Salesforce.

Can you post your code and the error you get? That way we can help you fix your issue with your Apex code.

Best regards,
Martijn Schwärzer
bujjibujji
Hi Martijn,

Thanks for your reply. I am able to connect with third party system. But i have a new problem like i am not able to update the third party as i need to use PATCH method. But HTTP Request class is not supporting PATCH method. Is there any way that i can acheive this. Please give me some ideas.

Thanks.
Martijn SchwarzerMartijn Schwarzer
Hi Bujji,

Yes, unfortunately the PATCH method is not supported (yet). I've had the same issue a while ago.

We solved it on the other end, by adding support for a POST call to the rest api. I hope this is also an option for you, that would be the easiest way.

Otherwise, you will have to use some form of middleware that turns your POST message into a PATCH message to the endpoint and passes back the response to Salesforce.

Hope this helps!

Best regards,
Martijn Schwärzer
bujjibujji
Thanks Martijn, probably i can try the first option.
Martijn SchwarzerMartijn Schwarzer
Hi Bujji,

I have found a way to do that:

You can just add '?_HttpMethod=PATCH' as a query string parameter to the endpoint and make a regular POST request.

That will work.

Good luck!

Best regards,
Martijn Schwärzer