Questions tagged [callout]

"HTTP Callouts" connect to a remote web server from Apex code.

Filter by
Sorted by
Tagged with
34
votes
2answers
31k views

HTTP Callout from Triggers

I have a trigger on the Custom Object that calls a class. That class makes an HTTP GET request to a Web Service. However I get the following error: Callout from triggers are currently not supported. ...
80
votes
2answers
13k views

Has anyone, ever, successfully invoked the Metadata API from within Apex?

While researching a semi-related question posted here earlier, I dug up some interesting and conflicting information regarding whether it's even possible to use the Metadata API from within Apex. I ...
12
votes
1answer
10k views

Error System.CalloutException: Callout from scheduled Apex not supported

i have created a schedulable class which has to trigger a batch job. The run method for the batch class will get list of data to process from a webservice callout. Now, i got the exception below. Any ...
32
votes
6answers
28k views

Testing HttpCallout with HttpCalloutMock and UnitTest Created Data

We have a callout to an external webservice that requires retrieving some data from the database via SOQL and then issuing an HTTP GET request, and performing various logic based upon the response. ...
12
votes
3answers
16k views

Post multipart without Base64 Encoding the body

I am trying to POST a PDF attachment to a Restful web service (not under my control). My issue is that I need to get put the raw bytes of the PDF into the Body of the request and whenever I call Blob....
12
votes
1answer
1k views

How do I unit test code that includes a callout?

This is a canonical question and answer developed by the community to help address common questions. If you've been directed here, or your question has been closed as a duplicate, please look through ...
21
votes
2answers
10k views

How can I make a PATCH HTTP Callout from Apex?

I need to make a PATCH http request. I made the rather incredible discovery today that I can't set an HttpRequest to use the PATCH method, as when sending the request I get a callout exception: ...
22
votes
2answers
3k views

Can we callout and chain a Queueable class?

I'll jump right into some code: public class ChainQueue implements Queueable, Database.AllowsCallouts { public void execute(QueueableContext context) { if(QueueUtil.hasNext()) { ...
6
votes
2answers
1k views

Getting CalloutException when testing Batchable class with Callouts and HttpCalloutMock

I'm trying to write test code for a Batchable class that AllowsCallouts. I've written a lot of other test code that uses HttpCalloutMock classes, and planned to do so for this class as well. And, ...
22
votes
2answers
3k views

Where to Store Token Auth?

Problem Statement I am working on an integration that will authenticate with a token. I need to pass it via header as follows: "Authorization": "Token abcdefghijklmnopqrstuvwxyz" I also need to ...
4
votes
3answers
41k views

Missing SOAP action header

Im trying to get the session ID of another user in the same org by sending the following request by using the data from my enterprise wsdl and its an developer edition. <?xml version="1.0" ...
3
votes
1answer
2k views

Making a callout in Apex to Marketing Cloud SOAP API

Afternoon! I've been trying to find some information as in how to add a certain email to a suppression list in Marketing Cloud via Apex, but at the end of the day, I haven't found any information I ...
20
votes
3answers
4k views

AWS Signature (version 4) in Apex

Over the past few days I have been struggling to create the AWS signature version 4 in Apex to send a request via query string, I have followed the step-by-step instructions for signing aws requests, ...
20
votes
1answer
32k views

How do I handle a 302 redirect response to my HTTP callout?

I am accessing an API, but when i debug the response it shows this message [Status=Moved Temporarily, StatusCode=302]. what should i do to access my required response.. my code is given below public ...
18
votes
2answers
5k views

WebServiceMock causing “CalloutException: You have uncommitted work pending” when creating managed package

I have a number of test methods that call Test.setMock(WebServiceMock.class, new SomeWebServiceMockImpl()); where SomeWebServiceMockImpl implements WebServiceMock. These test methods pass when I run ...
8
votes
2answers
512 views

Why aren't iterators in batch jobs lazy-loaded?

I have a batch job that needs to callout to an external web service and retrieve a variable number of records. Seems like a perfect use-case to have an iterator which performs the callouts until there ...
6
votes
1answer
1k views

Can I use Named Credential merge fields as URL parameters on the endpoint?

I have a named credential as follows: Name Test_Credential URL https://www.somesite.com Identity Type Named Principal Authentication Protocol Password Authentication Username foobar ...
7
votes
3answers
21k views

how to solve callout error? You have uncommitted work pending. Please commit or rollback before calling out

I have written inline Vf page to update the record value. The values are coming from a web service. While updating the record the detail page redirected to VF page. But the record was committed in the ...
2
votes
1answer
3k views

“Methods defined as TestMethod do not support Web service callouts” error when testing apex callout

I am trying to write a test for a trigger that is firing a future apex callout : The trigger calls the callBillingService method from this class: public class BillingCalloutService { //Implement ...
15
votes
3answers
6k views

Challenge with unit tests, mock callouts and running as a user

Background I am developing a number of business applications within a community. Many of these apps rely on callouts to another ERP system to verify or retrieve or push data. In order to adequately ...
8
votes
1answer
10k views

Why do I get 'PKIX path building failed' exception with my callout?

Error message :PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target Hello all please see the above ...
11
votes
1answer
2k views

Uncommitted work pending in unit test with trigger and queueable callout

I have an after insert trigger that invokes queueable Apex which makes a callout. The trigger and callout work fine in the UI and I don't get any errors in normal operation. However, my unit test ...
5
votes
2answers
5k views

How to create HttpRequest body as plain string from WSDL?

Is there an good way to (automatically) create proper request bodies from WSDL files just as a plain xml string? I need this for perfoming calls from APEX to different salesforce APIs, mostly for the ...
0
votes
1answer
317 views

test class with Batch and Callout [duplicate]

I have a problem with FeedItems in my Test class, it's very weird behaviour Does someone explain to me why this happens? Callout Class public with sharing class Callout { public static void ...
14
votes
1answer
2k views

Access MetadataAPI via JavaScript

We created an 100% native Salesforce IDE as a Managed Package which is using ToolingAPI and MetadataAPI via APEX. This works fine. But there is one thing which really bothers people after the ...
23
votes
4answers
6k views

Unit tests that need more than one WebServiceMock

I'm dealing with an odd situation where I need to call Webservice A to authenticate to Webservice B and Webservice C, all with different endpoints. I know how to setup mocks to test B and C ...
6
votes
1answer
347 views

Error on Batch Apex for sun.security.validator

I`m making calls to the outbound REST API from Salesforce via Batch apex. Most of the calls are working fine, except in some cases, Im getting below error. For example, if I run 200 batches (with ...
6
votes
2answers
4k views

Callouts to web services started failing with CalloutException: Server chose TLSv1

Today I started receiving the following exception when making callouts to external web services: System.CalloutException: IO Exception: Server chose TLSv1, but that protocol version is not enabled ...
5
votes
2answers
4k views

How do you use Batch for send more than 10 emails?

I have been watching how to implement the batch for sending more than 10 email but I get errors. When I send emails I have a limit 5 and also are sent several times to the same user email global ...
4
votes
1answer
857 views

Custom Auth Provider usage for unattended OAuth flow

I am attempting to make a REST callout to an API in our company that uses ApiGee as the OAuth2 provider using a simple client credentials grant type. Open-ID is not enabled and will likely not be an ...
11
votes
1answer
1k views

BURP Scanning a managed package

Salesforce have asked me to do a BURP Scan on my managed package before I submit it to the AppExchange. My Managed Package is built on the Force.com platform. It does perform a couple of callouts to ...
5
votes
1answer
497 views

AWS Signature Version 4 Using Named Credentials

Anyone tried Summer '19 Named Credentials using AWS Signature Version 4 successfully? Trying again to use External Services and first step is the Credentials. I created an IAM user with the ...
1
vote
1answer
248 views

System.UnexpectedException: Invalid parameter value for parameter “Decryption Exception”

I tried to execute some code in a sandbox and I got an odd error message: System.UnexpectedException: Invalid parameter value '****' for parameter "Decryption Exception". Looks like it happened ...
12
votes
1answer
3k views

Testing Batch Job with HTTP Callouts

Suppose I have the following: global class CMBatchRegisterUsers implements Database.Batchable<sObject>, Database.AllowsCallouts, Database.Stateful { global final String orgID = UserInfo....
12
votes
1answer
1k views

Managed package callout invoked from managed package extension causing test class failure

We have a managed package that has executes a HTTP callout from a trigger that calls a future method on the insertion of new records on a particular object. We have a managed package extension that ...
7
votes
2answers
2k views

System.AsyncException: Maximum callout depth has been reached

I have a System.Queuable job, on a particular Sandbox that is giving me issues. It works fine on other Orgs, but fails on this particular one. The job structure is this: Batch Apex job calls System....
3
votes
1answer
344 views

batch class doesn't execute all the batches

I want to send salesforce data to another system, but when I send the data through a batch class when I call the web service in the execute method doesn't execute all the batches, but if in the ...
2
votes
1answer
990 views

Make RPC/Encoded callouts from Apex

We have an application which we need to integrate with salesforce. Unfortunately this legacy application supports RPC SOAP calls only, we cannot use out of the box wsdl2apex to build the integration ...
1
vote
2answers
890 views

how to create an incident in serviceNow from salesforce(Case)?

I'm trying to integrate salesforce and serviceNow. If I create a new case in salesforce, that should be saved as incident in serviceNow. Here I developed some code but I'm stuck at mapping the ...
1
vote
2answers
863 views

Test class get error System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

I have almost tried all solutions available on internet but i still face the error. my Test class code is @isTest private class RegisterTest { @isTest static void existingUserCheck() { ...
1
vote
1answer
134 views

Getting System.CalloutException: You have uncommitted work pending [closed]

I am getting an exception of System.CalloutException: You have uncommitted work pending. Detail of the Exception is given Below: Exception: :System.CalloutException: You have uncommitted work ...
0
votes
2answers
641 views

Multiple Http Mock Callouts in a single test class

Hi so I'm trying to make a test class for my http callouts class. Now the problem is that I understand that I cannot make multiple DML and HTTP callouts in a single transaction but the third party API ...
17
votes
1answer
872 views

Apex Framework / library for consuming REST services

To consume REST services there is a lot of boilerplate code needed: Build Apex Objects to model the responses Code to deserialize REST responses to those classes Handling of HTTP requests, responses ...
12
votes
2answers
11k views

Call webservice with NTLM authentication

Is it possible calling a webservice using NTLM authentication from apex? It is a microsoft navision webservice, I tried to do it in java following this guide and it works.
10
votes
2answers
2k views

Is there a simple way to serialize execution of Batchable class?

I need to Geocode addresses on Account using an HTTP callout; the webservice will only service one address per callout. For this use case it is preferable to geocode the accounts immediately, rather ...
9
votes
1answer
1k views

Named Credentials and support for the OAuth2 Client Credentials Grant Type and alternatives

I have a requirement to authenticate to an external API for callouts using the OAuth2 Client Credentials Grant (This was helpful in referencing the different grant types for me). I would like to use ...
8
votes
1answer
3k views

What can cause “System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out”?

What else, other than insert/update/upsert/delete, can cause "System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out"? I've search the debug logs ...
10
votes
2answers
378 views

Guarantee only a single asynchronous job runs at a time

This is a bit of an odd one. We are interacting with an external system that does not support concurrency due to a bug which they are struggling to fix. We perform a HTTP callout, the callout takes ...
7
votes
1answer
3k views

Methods defined as TestMethod do not support Web service callouts - Causing tests to fail instead of skipped - Began 10-21-2015

Starting recently we are now getting this error during tests: Methods defined as TestMethod do not support Web service callouts Rather than saying "Test Method Skipped" they are failing and ...
7
votes
1answer
2k views

Number of callouts allowed from batch execute method showing zero?

I have the below sample code: global class BatchApexExample implements Database.Batchable<SObject>{ public Database.QueryLocator start(Database.BatchableContext bc){ System.debug('...