Questions tagged [apexrest]

Apex REST enhances the Force.com REST API to allow developers to create custom REST-enabled web services using Apex.

Filter by
Sorted by
Tagged with
0
votes
1answer
35 views

LWC: JS based Integration or apex based rest integration, which is better and why?

In LWC, what are the pros and cons of doing integration directly from JS (with help of methods such as fetch) when compared with normal apex based rest integration? Please consider the situations of ...
0
votes
0answers
29 views

How to retry the callout on http request timed out in rest apex callouts? [duplicate]

Below is the code. Can anyone tell how to implement retry logic when the 2 minutes http request get timed out. public static void sendOptyInfo(Set <Id> oppIdSet) { try{ for (...
-1
votes
1answer
26 views

How to delete records automatically and periodically , object cases? [duplicate]

I couldn't find a way to delete records from the case object automatically periodically with code apex please help me with this.
0
votes
0answers
29 views

How to call salesforce restwebservice from Browser

I have exposed an apex class as rest and i want to execute this in google chrome. Im using the below url https://instanceurl.my.salesforce.com/services/apexrest/getAccountTest/ im getting this error: ...
0
votes
1answer
27 views

When I trying to run this code getting error System.StringException: Unrecognized base64 character: :

global class SendGrid { private static final String ENCODING = 'UTF-8'; private static final String API_URL = 'https://api.sendgrid.com/api/mail.send.json'; private transient String username;...
1
vote
0answers
22 views

Generate Swagger JSON for an Apex REST API?

I've been finding documentation on how Salesforce can utilize API JSON generated by Swagger to generate code and implement APIs that way, but what I haven't been able to find is if it is possible to ...
0
votes
0answers
16 views

Create new lead Record with Lead custom field & relationship using SF REST API

I have a Lead object with some set of fields. I have created one custom Lead field & relationship with data type Lookup(Lead) which is Interested. I am using below REST API & format to create ...
0
votes
1answer
21 views

Creating duplicate leads via API calls

I have a rest API endpoint in Salesforce which accepts a payload from my application. On reception of the first request with a given email, it creates a lead. On subsequent requests, it finds the lead ...
0
votes
0answers
22 views

How to reset apex code on scratch org on source:push?

I am working on some custom apex code and I have stumbled on a problem: I have a class, for example: class Test { public static String CONST1 = "test1"; public static String CONST2 = &...
2
votes
1answer
28 views

Help Understanding How to write Test Class for Apex HTTP Post

So I've been through quite a few posts/questions already looking for enough information to have this "click" for me, but I'm still missing something. This is my first time working with ...
1
vote
1answer
34 views

Unsupported grant type when getting an access token for a Connected App from Jira but not from curl [closed]

Doing the following using curl works... curl "https://test.salesforce.com/services/oauth2/token" \ --data 'grant_type=password&client_id=CONSUMER_KEY&client_secret=CONSUMER_SECRET&...
1
vote
1answer
71 views

Exposing an APEX REST endpoint to be called by Jira

Built an APEX REST endpoint that handles an inbound PUT operation to update records in an SObject (Time_Entry__c). I want to trigger the PUT from a Jira Automation with a web request whenever a ...
0
votes
2answers
25 views

How “NextStartDate” field value get calculated for DatedConversionRate object

I would like to know how the calculation is happening for DatedConversionRate's nextstartdate, is it depends on some configuration setting?
0
votes
1answer
33 views

How to get OAuth 2-based authenticated access to REST APIs in a Lightning Community

I am trying to get (custom, Apex-based) REST API access for a (lightning) community user but keep hitting an error around access to the REST API's apex implementation. The specific error is: You do ...
2
votes
1answer
77 views

Special Characters in rest API URL

Is there any way to handle a & in a params being sent in the URL of a restAPI call. So that the system doesn't think this the end and start of a different params? The URL being sent is below: /...
1
vote
1answer
50 views

why POST request on POSTMAN always respond with 405?

In salesforce apex, I have one custom API, It's working fine on the workbench but not work on POSTMAN, I have an access token, this works fine with GET method, but why not work with POST in POSTMAN? ...
2
votes
1answer
33 views

My test class (not annotated seeAllData=true) actually sees data for ContentNote SObject

I know test methods should not see any data except the data created in test context, but when I run the test below, the query returns an org record. It should not I have a REST class like @...
0
votes
0answers
34 views

Session expired or invalid on using access token

I have created a connected app in which I have selected the OAuth Scopes "Access and manage your data (api)" and "Full access (full)" through the consumer key and consumer secret ...
3
votes
2answers
800 views

How I can know who is calling a REST resource?

We have the following REST endpoint @RestResource(urlMapping='/multi/v1/Contact/ContactId__c/*') global with sharing class ContactMultiV1 { @HttpPost global static MultiV1.SuccessResponse[] post(...
0
votes
1answer
42 views

Getting invalid header line: “SFDC_STACK_DEPTH: 1” error

While posting a HTTPs request through apex I am getting below intermittent error . *64545242 client sent invalid header line: "SFDC_STACK_DEPTH: 1" while reading client request headers, ...
0
votes
1answer
23 views

Sending PDF file from Salesforce to XERO, but it's not happening

I want to send PDF file which is generated by VF page from Salesforce to XERO. But I'm trying to send but it's not happening XERO syntax, it receives like below format POST /api.xro/2.0/Receipts/...
10
votes
1answer
570 views

Custom REST controller to access Auth.AuthToken.getAccessToken returning null

Following on from a previous question: How to access OAuth Token stored in NamedCredential using Apex for use in other third party application I've created a custom REST endpoint which proxies ...
1
vote
2answers
62 views

Consume REST API using Basic Authentication or oAuth via client credentials grant

We want to take code we developed in Salesforce and expose it as a REST web service an external application. The external system can use either Basic Authentication or OAuth 2.0 with grant_type=...
0
votes
0answers
33 views

Per User Authentication for External Service

As part of my use case, I need to integrate different external sources from Salesforce . All the authentication has to be per-user and this whole thing needs to be part of managed package. Now the few ...
0
votes
1answer
82 views

Create a test class for RestResource class with a response code

I have a @RestResource class which receives data from a third party, finds the matching record and updates it, then returns a success/fail to the third party. I've just added the RestContext.response ...
0
votes
0answers
12 views

How to create and assign audience for page and components in apex class?

I'm trying to automate the post deployment steps for my project in which i want to create and assign the audience to the page and the components, is it possible to do it from the apex class..
0
votes
0answers
88 views

Case.SobjectType.getDescribe().getRecordTypeInfos();

Case.SobjectType.getDescribe().getRecordTypeInfos(); returns null even when the user profile has Record types assigned. Prototype of code below : List<Schema.RecordTypeInfo> rt = Case....
0
votes
2answers
39 views

How to form JSON with salesforce field values in apex/Salesforce

I have created SF to SF connection to put standard object cross org, getting error related to JSON response as 400 Bad Request. Error as: Unexpected parameter encountered during deserialization: ...
0
votes
1answer
23 views

Apex Wb Service POST method is not creating multiple child records on a parent record

I have a Master-Detail object in my org, Ticket__c(parent/master) and Ticket_Task__c (detail/child). I created a Web Service whose PUT method is successfully creating new tasks for a given ticket ...
1
vote
2answers
78 views

JSON Parsing error when serializing a PUT request

I have created the following Apex class. This is a web service that basically takes a list of JSON response in the following format: [ {"ticketName" : "INC0611231", "...
0
votes
1answer
75 views

Pass a JSON List for a PUT method in my APEX Web Service

I have written a REST web service with a HttpPut method where it works great (updates the records) if I pass a JSON similar to this: { "ticketName" : "INC0611231", "Status&...
0
votes
0answers
83 views

Getting checkmarx FLS_Create Error in apex

Checkmarx is giving me the FLS_Create error in the below code. cv.PathOnClient = docName; cv.VersionData = requestbody; cv.ContentLocation = 'S'; cv....
0
votes
1answer
44 views

Getting JSON_PARSER_EXCEPTION “Unexpected parameter encountered during deserialization: saver ”

I am trying to use the Quote Generation API for Salesforce, I referred the below link for reference https://developer.salesforce.com/docs/atlas.en-us.cpq_dev_api.meta/cpq_dev_api/...
0
votes
0answers
39 views

I am writing test class for the class and I am getting an error Missing '<EOF>' at 'request.requestBody'

@RestResource(urlMapping='/api/Etg_Order__C/*') global with sharing class orderPostClass { @HttpPost global static String doPost() { list<Etg_Order__c> Etgorders = new list&...
-3
votes
1answer
24 views

Getting Error while running the class

You have uncommitted changes .. I am running it from anonymous Below is my class, i am not doing any DML ,just hitting api I am hitting the api to get different salesforce instance Status and sending ...
0
votes
1answer
338 views

Empty request body using POSTMAN in Apex REST

I'm making a apex rest class and trying to test it with POSTMAN. I already manage to do the authorization part succesfully, but when i make the call i receive as a response this error: After viewing ...
0
votes
0answers
12 views

Temporarily Disable Users updating forecasts

We are using collaborative forecasting with type of Opportunities by territory. I have a need to disable users from entering their forecasts during certain period of time in a week. For example, every ...
0
votes
0answers
83 views

Help on Illegal assignment from List in Apex

How can i place below data Into Map : ( caseInfoWrapper: [carrierId=, partyId=a1K2F000000lWJrUAM, product=SI, productType=Whole Life, stateId=AK] ) ...
0
votes
1answer
102 views

How to display 401 errors from Apex class as toast message in lightning component

HttpRequest req1 = new HttpRequest(); req1.setMethod ('GET'); req1.setHeader ('Authorization', 'Bearer ' + accessToken); req1.setEndpoint (...
0
votes
0answers
26 views

how to do a POST using content type as form-data apex

I am trying to do a POST using form-data. I am not sending any file content. This will be triggered from a trigger Contact cont = [select Email from Contact where Id = '0031X00000V7BN3QAN']; ...
0
votes
2answers
46 views

Rest API Test Class Problem

I am having some problem while testing my rest API Class. My main class is as mentioned there @RestResource(urlMapping='/ONB2__Subscription__c/*') global with sharing class SubsRecord { @HttpGet ...
1
vote
1answer
62 views

Responsive JSON data

Hi my requirment is : In RestExplorer, Get Method, When i pass below URL # /services/apexrest/partyInquiry?recordId=a1K2F000000Wsom I can get Results below Structure : { "caseInfo": { &...
1
vote
0answers
35 views

Exposing Apex REST Services using OpenAPI [duplicate]

I'm trying to find the recommended approach for exposing custom Apex REST services using OpenAPI(fka Swagger). I found most articles on Salesforce consuming OpenAPI spec in external services but ...
0
votes
2answers
158 views

Public REST Service Access Error

I am moving a guest user sites page REST service from a sites page implementation to a public guest community. It worked fine as a sites page REST service but I am having trouble porting it to a ...
0
votes
1answer
44 views

How could I get the full URL in apex class

How can I take the full url without affecting the "&" if i redirect to this page: https://XXX.XXX.force.com?pay=BXXXB&PA83747474&TOKEN=23444848 for example. I catch the url using:...
0
votes
0answers
229 views

Apex REST API “HTTP Method 'GET' not allowed. Allowed are POST” Issue

We have created an Apex REST API which is using POST method. when we consume the API from postman with below URL, https://TestDomain--pcsandbox.my.salesforce.com/services/apexrest/v1/updateAll but ...
0
votes
1answer
189 views

Apex rest service issue with HTTP Post method when i Access from Postman

i created Apex rest service and @HttpPost method , i am able call POST method & got data in request body successfully from workbench. but i had issue with when i try to access from Post man. i ...
0
votes
0answers
66 views

How to Queue inbound Rest API request

Is there a way, we can execute the inbound rest api callout to be queued like the outbound callout can be queued using future or Queueable interface?
1
vote
1answer
243 views

Grant types supported by the Rest API [closed]

I have created a Apex Class and exposed the data as a REST API like below. global with sharing class ReteriveSFAccountData { @HttpGet global static void doGet() { try{ } } ...
2
votes
0answers
90 views

Using Salesforce mobile SDK how do I call an Apex REST endpoint?

In my scratchorg I've got: @RestResource(urlMapping='/Test/') global without sharing class RestTest { @HttpGet global static String test() { return 'cat'; } } And in workbench I'...

1
2 3 4 5
11