Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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

-1
votes
0answers
15 views

Coverage for callout method class

Im trying to get the coverage for callout method class.. my testclass seems working but when I check the callout method, it only cover 63%.. for the 1st process, I want to get the "count" data from ...
1
vote
1answer
14 views

Unauthorized endpoint error due to port 444?

I am getting error during callout although I have added the url in remote sites. Can this be due to port 444 which other system has provided? What I can do to fix this as this is external system url ...
-2
votes
0answers
21 views

Need help how to create test class for webservice method

How to get the coverage for webservice method? I tried to create test class just like normal class method but getting error "Methods defined as TestMethod do not support Web service callouts".. I ...
-3
votes
0answers
23 views

Please help me how to write rest api code for image field integration [on hold]

I have a website form in this form there is an image field and I want to submit image in Salesforce Document object.
3
votes
0answers
37 views

Trying to call API through Apex with custom security certificate but getting CalloutException

I'm trying to use Apex to call some API endpoints to do some validation for my company. There are some specific properties of these APIs that make it a bit tricky: The APIs are hosted on self-...
0
votes
0answers
25 views

System.CalloutException: handshake_failure

I am getting the following error when i try to call an external service using SOAP: System.CalloutException: IO Exception: Received fatal alert: handshake_failure The external system is not ...
1
vote
1answer
38 views

Alternatives for handling a Long Running Transaction

I have logic inside an Apex Class that will be invoked from a Lightning Component. There are three sequential callouts that will be sent to an External System whenever its method is Called. As per ...
0
votes
0answers
27 views

Web service callout failed: Unexpected element. Parser was expecting element 'http://schemas.xmlsoap.org/soap/envelope/:Envelope' but found ':HTML'

We are integrating salesforce with SAP system. When we send request from SOAP UI to end Point url. It sent successfully and I received the expected response. But when I am sending callout request ...
0
votes
1answer
25 views

Http send is not working with encoded url parameters

I created one class to make http callout to ftp server.I am using Http mock for test class.Sometimes ftp folders are created with space and it is required to encode the file and folder name in ftp url....
0
votes
2answers
35 views

How can I send an error from HttpPost to Callout if ExternalID is the same?

I still can't send to my Callout right status code. I have an Item object in Org2 that I can post from Org1 (in Org1 is Tool object that passes its fields to THIS (Item) object). Item has ExternalID ...
0
votes
1answer
23 views

Parsing XML Response body in Apex

I want to parse the XML body and want to capture the url from the xml body in the list of string which i have created but i am getting Null values in the list Respnse body:- <retours> <...
0
votes
1answer
29 views

How to send error from HttpPost to Callout if ExternalID is the same?

I have an Item object in Org2 that I can post from Org1 (in Org1 is Tool object that passes its fields to THIS (Item) object). Item has ExternalID field that takes the ID from Tool. How can I send an ...
2
votes
1answer
162 views

How to read JSON that contains field that can have different types

I am writing a callout in Apex with returns a JSON file with a field that does not have a consistent type. The JSON returned is quite complicated, so I have been trying to read the JSON with a Apex ...
1
vote
1answer
31 views

How to convert Json string with adminbooster and call a value

I am newbie trying to find a wordflow which makes it easy to convert JSON strings to apex I used adminbooster but get for example public cls_0 0; public class cls_0 { public cls_0 0; throws an ...
0
votes
2answers
28 views

How to deserialize json list, error: Invalid conversion from runtime type List<ANY> to List<or_leadsJSON>

I an trying to deserialize a Json string to use in my callout but get the error Invalid conversion from runtime type List<ANY> to List<or_guestsJSON> Callout HttpResponse response = ...
5
votes
0answers
52 views

Tooling API in Apex - polymorphism, generic query() callout?

I am working on Salesforce project heavily depending on use of Tooling API (we are executing tests on remote SF organizations and gathering results). What bothers me is I cannot use polymporphism ...
1
vote
1answer
39 views

Methods defined as TestMethod do not support Web service callouts - Unit Test [duplicate]

We have a custom object called 'support' - we have process builder configured for this object. in one of the process builder action it will invoke Apex (Invocable Method). This will trigger a callout ...
4
votes
1answer
46 views

How to avoid duplication when using Apex Dropbox API Framework or any other Frameworks/SDKs?

BACKGROUND I need to implement an integration with Dropbox using its REST APIs. I don't want to reinvent the wheel so I decided to use Apex Dropbox API Framework. Although it's a bit outdated (it ...
0
votes
1answer
32 views

How to use if(!Test.isRunningTest()){} for a specific test

I have a class with a callout and a unittest mock for the callout. The callout has a scheduler. If I create a unittest for the scheduler the scheduler tries to do a callout If i use if(!Test....
0
votes
1answer
21 views

How to test 'throw new MyException()' in HttpResponse Callout?

I always get an Fail when try to test the negative scenario. How can I fix it? Sorry, I'm just learning. Callout: public class MyException extends Exception {} public class Token{ public String ...
0
votes
1answer
24 views

How to pass query variable from soql into loop

I am trying to bulkify a callout where I want to pass the recordtype in my loop but I get: Error: Variable does not exist: RecordType If I try public RecordType personAccountRecordType I get ...
1
vote
1answer
43 views

What are the design patterns how to do a batch callout

I know some basics on callouts but would like some advice on doing multiple callouts. Requirements: I have an external system where guests are registered this could be large amounts. I have to get ...
0
votes
1answer
25 views

How can I test my Web Token and posted record from Post Callout?

I try to use HttpCalloutMock to test my post callout. But I become System.NullPointerException: Attempt to de-reference a null object. I need to test and web token, and posted object. I'm just ...
-1
votes
1answer
27 views

How to fix Attempt to de-reference a null object in test for Post Callout?

I become an error System.NullPointerException: Attempt to de-reference a null object in my test: public class Token{ public String accessToken{get;set;} } public static String accessTokenBody(){ ...
1
vote
1answer
22 views

How can I test Post Callout with web token's access? HttpCalloutMock

My POST Method (data for web token - is my custom object's fields): public class Token{ public String accessToken{get;set;} } public static String accessTokenBody(){ //our web token (data is in ...
0
votes
1answer
31 views

How to test access token for HTTP callouts?

I have an access token for my HTTP callouts. How can I test it if I wanna use Static Resource? But I can also use the HttpCalloutMock Interface. it doesn't matter My access token is in custom object. ...
1
vote
1answer
35 views

How can I test Callouts with HttpCalloutMock?

How can I test this method? I try the test code from trailhead but can't make any coverage. Callout: public class Token{ public String accessToken{get;set;} } public static HttpResponse ...
0
votes
2answers
17 views

How to do or store a 1 time callout to a custom setting

I have an integration where I need to get the agency of my endpoint. Once I have the agency this wil be used for all the rest of the callouts. I would like some advice for the following: Is there a ...
0
votes
2answers
25 views

how to get a value after from result callout

I have the following where the result format of the callout is the following: [ { "uid": "72852a55-5be3-496c-904c-fc3fd261f0a4", "name": "Responseev Agency" }, { "uid": "66852a55-...
3
votes
2answers
210 views

User Friendly Handling of Exceptions in Future Methods

Background Salesforce is integrated with an external system, like Xero Accounting. When the User updates an invoice status 'Sent' Salesforce creates it in Xero. Process Builder calls an @...
0
votes
1answer
28 views

How to avoid: Error uncommitted work pending in my testclass

I am doing do a callout trough a processbuilder with a future call. Before I do the call I get some variables from a custom setting. When I do an insert in my testclass for my custom setting I get the ...
0
votes
2answers
39 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 ...
0
votes
1answer
32 views

Test Class Not Covering Original Class

So I am trying to cover this Chatter Answers Class so I can increase my system's code coverage. The test class runs successfully but the original class is still 0% covered. What do I need to do to ...
0
votes
1answer
38 views

How to use @invocableVariable in Callout

I want to use the processbuilder to do a callout. In this callout I want to add some variables from the current record but get variable does not exist see below: global class or_service { @...
0
votes
1answer
17 views

Callout error Invalid conversion from runtime type List<ANY> to Map<String,ANY>

I just followed a trailhead on callouts and I am trying to get some values from an endpoint. My debug shows me my status is ok but I get an error on line 17: Callout error Invalid conversion from ...
0
votes
2answers
40 views

DELETE a record by REST API without @HttpDelete

I need to make integration between Org1 and Org2. We created a callout POST. When we create an object in Org1, we also create an object in Org2. POST work. All is Ok. Now I need also delete an object ...
2
votes
1answer
34 views

Doesn't a Named Credential handle OAuth2?

Reading this doc from Salesforce, it was my understanding that a named credential handled authenticating when using it to make a callout. I'm going to go out on a limb and say that it probably does, I'...
0
votes
1answer
33 views

HTTP Callout with form-data not working

I am making a callout to a payment gateway, and initially I tested the API using Postman app. And the response is given Now, that I transform all that to Salesforce Apex, I am getting following ...
0
votes
1answer
41 views

System.NullPointerException: null argument for JSONGenerator.writeStringField() in POST Method

I have a custom Obj, and try to realize a POST method. But I get an Error: System.NullPointerException: null argument for JSONGenerator.writeStringField() What is wrong here? public static ...
0
votes
1answer
34 views

Apex Callout from one Org to another with method GET

Org 2 has GET Method: @RestResource(urlMapping='/jobShow/*') global with sharing class RestJob { @HttpGet global static List<Job__c> getJob(){ List<Job__c> jobList; ...
1
vote
1answer
355 views

“message”:“INVALID_HEADER_TYPE”,“errorCode”:“INVALID_AUTH_HEADER” received

I am trying to call a rest resource within the same org (Because I am inserting records of an object developed by 3rd party and they strongly advised us to not do any DML directly rather they have ...
-2
votes
2answers
32 views

Methods defined as TestMethod do not support Web service callouts -ApexPages.StandardController controller [duplicate]

I am trying to test my Apex class, getting following error response "Methods defined as TestMethod do not support Web service callouts" public with sharing class CreateOrder { private Boolean failed ...
1
vote
1answer
48 views

Salesforce calling external application using OAUTH

I need to call an external service FROM salesforce Authenticating against the External application is done via OAUTH so basically I need to write APEX code that uses HttpRequest and passes in the ...
3
votes
1answer
46 views

batch apex finish method to schedule another batch job with scope of 100 due to callout limit

The schedule_batch_mdm_role_definition I believe is working fine. global class schedule_batch_mdm_role_definition implements schedulable { global void execute(SchedulableContext sc) ...
0
votes
2answers
40 views

How do I return a value from a callout method to a trigger so that I may validate field values against a web service?

I'm trying to validate a particular field on insert or update against a web service. Before the record is saved, the data is sent over to the web service, and it returns a Boolean indicating whether ...
1
vote
1answer
52 views

Unit testing with SOAP and REST callouts

My project assumes quite big integration with external webservices. Unfortunately first major service is SOAP and second is REST. Problem is that there are getting more and more places in the code ...
0
votes
1answer
20 views

Invalid Type and incorrect signature error in Future class

Hi we have a @future class created, however we have this error as per the screen shot below Please find the code below public with sharing class Addressfuture { public Addressfuture() { List&...
0
votes
1answer
31 views

Can we use Named Credentials with this Weird API?

In order to do something, we need to make call outs to an external server where the URL takes the format: http://www.example.com/path/{external_id}/doSomething?api-key={api-key} The external-id ...
0
votes
1answer
142 views

null argument for JSONGenerator.writeStringField()

Im getting the error 'null argument for JSONGenerator.writeStringField()' when I call the below class from Visual Page. Visualforce Page Code: <apex:page standardController="Lead" extensions="...
1
vote
1answer
56 views

HTTP Callout from salesforce to private server URL(VPN connected)

Can we hit a private server URL with HTTP request from Salesforce ?? or the server should always be public. I have make the Post callout which was written in Rails (hosted on Private server- VPN ...