Skip to main content
33 votes
Accepted

Queueable - Callout not allowed from this future method

You need to add Database.AllowsCallouts to your class, not @future(callout=true). The error is erroneous. public class getAccountUpdatesfromEndpoint implements queueable, Database.AllowsCallouts {
sfdcfox's user avatar
  • 497k
15 votes
Accepted

Problem with Process Builder Invocable Method and Webservice Call out

Apex can be annoying like that: limitations in termos of callouts and DML. What we've done to work around that is to make callout in the future method. Your invocable would call the future and pass ...
mkorman's user avatar
  • 4,056
13 votes

Can you call a webservice from a Platform Event Trigger?

Older question but felt compelled to add an answer, as I was confused by what was presented here so far. If you are asking "can I make an Apex HTTP Callout from my Apex Platform Event Trigger?&...
Grekker's user avatar
  • 1,092
13 votes
Accepted

Metadata API error while reading Picklist: Web service callout failed: Unable to find apex schema info

This is a very similar scenario to what is occurring in Tooling API in Apex - polymorphism, generic query() callout? and is caused by an underlying limitation in Wsdl2Apex and WebServiceCallout.invoke(...
Daniel Ballinger's user avatar
12 votes
Accepted

Passing a List of Custom Objects to Batch Apex

You can use this signature instead: public List<SObject> start(Database.BatchableContext context) { return myRecords; } Please note that your batch classes do not need to be global and you ...
Adrian Larson's user avatar
  • 151k
12 votes

Metadata API error while reading Picklist: Web service callout failed: Unable to find apex schema info

Taken from Issue # 225 on their repo. Error occurred when obtaining a custom picklist fields CustomValue. Error: System.CalloutException: Web service callout failed: Unable to find apex schema ...
battery.cord's user avatar
  • 8,845
11 votes
Accepted

Use cases for Enterprise WSDL vs Partner WSDL

A critical difference between the two is how change is handled i.e. what needs to be done when the org the WSDLs are generated from's structure changes - when new fields and objects being added. In ...
Keith C's user avatar
  • 136k
11 votes

Create a Time Delay in APEX without Exceeding CPU Limit

If your current context allows PageReference.getContent, you can get your approximate 2 second wait using a Visualforce page. Controller public class DelayController { public DelayController() { ...
sfdcfox's user avatar
  • 497k
10 votes
Accepted

Future Method and Static Variables

Static variables in Apex only retain their value through the course of a single transaction. Future methods by nature execute in a separate transaction, which means that your static variables are ...
David Reed's user avatar
  • 93.2k
9 votes
Accepted

How to consume a soap web service using workbench?

Here is how I have tried using workbench to test a SOAP web service. Hope this helps. First you have to get the session ID by passing a Soap request(I copied the request XML from SoapUI) to login ...
Saroj Bera's user avatar
  • 14.8k
9 votes
Accepted

Not able to post data to Http with content type: application/x-www-form-urlencoded

I think you need to URL-encode the parameters in your payload. The password needs it in this instance, and it's worth doing for the username too. So, you would have: String payLoad = 'grant_type=...
Aidan's user avatar
  • 13.7k
9 votes

Publish and/or subscribe to Platform Events between separate Orgs?

Response from Jay Hurst (Salesforce PM): Subscribing and publishing between orgs is not something that is natively supported today. We have discussed it, but it is not on the short term roadmap. You ...
Daniel Ballinger's user avatar
8 votes
Accepted

executing web service using postman

You can't connect Salesforce without authentication so you need to first generate app key and secret and then you will use that to call your api. You can follow below steps: Create Connected app in ...
Himanshu's user avatar
  • 10.5k
8 votes

what is difference between JSON generator and JSON parser?

The two are opposite features. The JSONGenerator takes data input and outputs JSON strings. The JSONParser takes JSON string input and outputs objects. If you're sending data to an outside source, ...
sfdcfox's user avatar
  • 497k
8 votes
Accepted

How do I Call the Salesforce API from a Lightning Component?

You have to manually replace the Session ID in your request body/header . In named credentials we have options to use the Merge fields in header/body @AuraEnabled public static String getOrgLimits()...
Pranay Jaiswal's user avatar
7 votes
Accepted

Access one methods input parameters in another method of same class

There are two different way to go about it. You could make static variables to hang on to this information: static String requestFirstName; @HttpPost global static String doPost(...) { ...
Adrian Larson's user avatar
  • 151k
7 votes

Trigger : making API call to validate record creation?

No, it is not technically possible. Synchronous callouts in Triggers are not allowed. There is an Idea to have Salesforce do this, but it's already a decade old, and may never be implemented. The main ...
sfdcfox's user avatar
  • 497k
6 votes

Method defined as testMethod do not support web service callouts, test skipped

Methods defined as TestMethod do not support Web service callouts Stack Trace: null This error occurs because web service callouts are not allowed in Test class. To bypass callouts add ...
Arjun's user avatar
  • 161
6 votes
Accepted

What is the difference in HTTP callout and SOAP & REST api?

An HTTP callout is code that you write within Salesforce to (generally) call out to an external API over HTTP. REST and SOAP are types of APIs. So, you could make a callout to an external SOAP API ...
Ryan Elkins's user avatar
  • 7,687
6 votes

How to test with webservice method

The issue is not unique to "testing a webservice method" it is an error in your code. You test this webservice method just like any other method and can essentially ignore the webservice keyword for ...
Eric's user avatar
  • 54.2k
6 votes
Accepted

Generate PDF with REST Web service

See getContentAsPDF() after insert a record in the same excution context that explains that the PDF generation call won't see any changes made in the transaction that calls it. If you don't require ...
Keith C's user avatar
  • 136k
6 votes
Accepted

JSON Parsing of REST response

Don't bother using JSONParser. It's inefficient, and really only meant for porting Java code, as far as I can tell. Since you're only concerned with a few elements, you can just do the following: ...
sfdcfox's user avatar
  • 497k
6 votes
Accepted

Is there a zero-downtime way to rotate the server credentials used by force-wsc?

A properly written force-wsc app (or any other SOAP-based application) won't immediately be affected by password change; this is because a session remains valid even if the username or password for ...
sfdcfox's user avatar
  • 497k
6 votes
Accepted

Create a Time Delay in APEX without Exceeding CPU Limit

One approach you could take (this is fairly architecture-dependent) is a chained Queueable. Design a tiny Queueable class that takes a taskId parameter and keeps it in an instance variable. Then, your ...
David Reed's user avatar
  • 93.2k
6 votes

Does an update called in an @future method count as being in the same transaction as the method that called it?

Executing a @future method counts as DML for the purposes of mixing callouts and DML. You can demonstrate it for yourself with a simple Minimum Viable Reproduction (MVR). public with sharing class ...
Adrian Larson's user avatar
  • 151k
6 votes
Accepted

Batch Apex - Static List not available in finish method

In batch jobs, static variables don't maintain state - they are re-set in each transaction. If you want to maintain state and access it in the finish method use member variables. Here's the relevant ...
PartOfTheOhana's user avatar
6 votes
Accepted

Method does not exist or incorrect signature: void send(System.HttpRequest) from the type System.HttpRequest

You instantiate an Http instance, which has the send method. Incorrect HttpResponse response = HttpRequest.send(request); Correct HttpResponse response = new Http().send(request); The HttpRequest ...
Adrian Larson's user avatar
  • 151k
5 votes

HTTP Callout from Triggers

The use of a Queueable Apex method is likely preferable to a Future method. If another future or batch method is what triggers your trigger, you'll encounter this error message. Future method cannot ...
blimmer's user avatar
  • 151
5 votes

Accessing Named Credentials' data in apex

One option is to use Merge Fields for Apex Callouts That Use Named Credentials. This won't explicitly give you access to the data from the named credential in Apex, but it will allow you to alter how ...
Daniel Ballinger's user avatar
5 votes
Accepted

Apex rest response: cyrillic characters encoding issue

Unfortunately I couldn't reproduce your bug, may be you've missed something, or it's 3rd party problem. Please find my example below: global class SalesOrder { global String name; //contains ...
Ilya Lepesh's user avatar
  • 4,125

Only top scored, non community-wiki answers of a minimum length are eligible