Questions tagged [apexrest]
Apex REST enhances the Force.com REST API to allow developers to create custom REST-enabled web services using Apex.
592
questions
0
votes
1
answer
26
views
Account deletion job based on object relations
I have a requirement for creating a job for deleting the accounts that do not have related cases, opportunity, Lead.
The 3 objects can also change in future and new object to be checked can be added ...
-1
votes
1
answer
44
views
"Required" attribute on a property of a Class in APEX?
I have a request class used to call into a REST endpoint for an APEX class.
I wish to mark a property on the class required so that I do not need to manually validate the field.
How is that done?
...
0
votes
0
answers
27
views
Missing required 'subjectId' parameter for Sending a Direct Message Connect REST API
Send a Direct Message
URL above is giving me the endpoint and body for sending a direct message in community. When run in workbench, the DirectMessage, DirectMessageFeed, and FeedItem record was ...
-2
votes
1
answer
45
views
To have different data type for same variable in Rest API Request body
I am trying to wrap a request body from callin request which has a variable but values can be different data types.
Example request body 1 :
{
RecordId:"cncjdn"
}
Example request body 2 :
{
...
0
votes
0
answers
41
views
Salesforce OAuth Token endpoint certificate not accepted
We're currently working with Bank of America to provide an exposed Rest Service that they can use to send in financial data. We are currently running into a roadblock, in that they aren't able to ...
-4
votes
1
answer
111
views
I'm sending a JSON Body from Postman to hit Apex, but I'm getting a deserializing error
I'm using below payload from postman and trying to hit an Apex class.
{
"First_Name__c": "elon",
"Last_Name__c": "musk",
"Email__c": "...
0
votes
0
answers
111
views
Impossible to get the Grouping columns (count) if the RowCount button from the UI in Salesforce report is Unchecked
I am hitting this rest API end point in Apex in order to get Salesforce Report Data.
String dash_url = '/services/data/v35.0/analytics/reports/'+repId+'?includeDetails=true';
It fetches me result and ...
0
votes
0
answers
100
views
Connecting AWS API Endpoint to Salesforce to Apex REST
My company tasked me to look into end-to-end event flow between AWS and Salesforce using the newly released Event Relay. I successfully followed the guide, sent CDC events from Salesforce to AWS, and ...
1
vote
0
answers
400
views
How to pass JSON data in the REST API URL without misinterpreting double quotes?
Hello Salesforce community,
I'm currently working on integrating with a REST API and facing an issue with passing JSON data in the URL. Whenever I try to include JSON data, specifically the provided ...
0
votes
0
answers
24
views
Unable to get full code coverage for a SF trigger after update [duplicate]
I have a simple Apex trigger, written for an object called Application__c, and it fires after the "Shipping_City__c" field changes:
1.trigger MyTrigger on Application__c (after update) {
...
1
vote
2
answers
93
views
Invalid type when assigning values to wrapper
I have a nested wrapper class but I am failing to understand how to assign values to the variables of the nested class.
public class Req_Wrapper {
public Envelope Envelope {get;set;}
public ...
1
vote
1
answer
149
views
Most Appropriate HTTP Method for Query with Optional Upsert?
I have inherited a REST endpoint that has one key action it performs, named find. This action will generally just query for any matching resources, rank them, and return the most favorable result. ...
2
votes
1
answer
427
views
401 Unauthorized Error on calling REST API from an Invokable Method called by flow
I have a flow and this flow calls an invokable method (where callout = true) that calls the Org REST API to update a Slack ViewDefinition.
The method works perfectly when called from an Anonymous ...
0
votes
0
answers
96
views
Attach multiple files to record via API
I recently started to work with API and postman.
In this case, I need to attach multiple files to a record via REST API
Currently I am only able to attach a single file to a record in salesforce via a ...
2
votes
1
answer
426
views
Retrieve Blob Value from Composite API
I was able to retrieve the response from the Blob Retrieve endpoint
/services/data/v55.0/sobjects/Attachment/OOPXXXXXXXXXXXXXXX/Body
but when i use composite request
endpoint: /services/data/v55.0/...
0
votes
1
answer
49
views
How can I add the RestContext.response in the batch class finish method?
I am creating a REST class wherein all the processing is done by a batch class. I would want the RestContext.response line to be made after the execute method. But it returns this error: "System....
0
votes
0
answers
224
views
AWS S3 delete multiple files: signature does not match the signature you provided
I'm trying to use an apex class to remove multiple files from any specified S3 bucket, but at the moment of sending the request, I recieve the following response:
SignatureDoesNotMatch The request ...
0
votes
2
answers
284
views
How to bypass Apex DML transaction limit of 10k records? (cannot use Batch)
I am trying to implement a solution that will allow users to create 10k+ records via UI.
Basically, there is a custom component that allows multiple record creation.
There could be 20-50k records, so ...
1
vote
3
answers
307
views
Synchronize Data between External System and ISV app
My AppExchange Managed Package and its related External System share a central data object. Records of those objects can be created, modified, and deleted both in Salesforce and the External System. I ...
-1
votes
2
answers
312
views
Use a date field on a Rest Query In Apex
I am trying to make a rest callout from one Salesforce org to another and I am using the following query in the rest end point
DateTime sdt = DateTime.newInstance(startDate.year(), startDate.month(...
0
votes
1
answer
156
views
Nested Json not detected
I'm trying to parse a nested JSON through a REST Api but somehow it is not getting read. For example: I'm passing a JSON like this in my request body.
[
{
"first":"I like sfdc",
&...
0
votes
1
answer
220
views
Issues with SOAP API login callout
I have the following piece of code that used to work before:
Custom_Data__c cData = [SELECT Password__c, Security_Token__c, Username__c FROM Custom_Data__c WHERE Name = :Constants....
-1
votes
1
answer
202
views
How to parse a json having Rows and Columns
I have the below JSON and want to parse it out to get the data. But the JSON format is in Rows and Columns.
{
"returnValue":{
"columnNames":[
"RowID",
...
0
votes
1
answer
87
views
How to establish Unique reference between parent child in apex rest insert
I have a requirement to insert a 2 level nested JSON structure in Apex.
I have 2 objects created, say, objA__c and objB__c.
objB__C has Master Detail relationship to objA__c.
objA and objB items can ...
0
votes
1
answer
163
views
wrapper class does not match with json resulted from POST request
I have this apex class (coded by another developer)
@RestResource(urlMapping = '/thunder/contapj/*')
global class Thunder_SVC_ContaPJ {
public static Log_de_Integracao__c log = new ...
0
votes
0
answers
272
views
JSON Exception for Restful Apex Service in test class
Creating a Salesforce REST Api to create a contact when json is posted to it from workbench and my code functions correctly but my test class gives me a weird error that I am not sure how to fix. The ...
1
vote
0
answers
224
views
Deploy Metadata with Apex Testing Using REST : No package.xml found
I have explored below two options to deploy metadata into my salesforce account.
Option 1:
Bundle zip file is available here: bundle zip
I am able to upload the bundle zip using workbench Workbench ...
1
vote
1
answer
156
views
HttpPut methods do not support parameter type of [user defined type]
I'm at a loss. This class already compiled, was deployed, and has been working fine in production for over a year. Upon updating it, I'm now getting:
HttpPut methods do not support parameter type of ...
0
votes
2
answers
416
views
Custom fields not being saved
I'm using propertybase to create contacts via salesforce (it uses apexrest REST API) and I followed this guide: https://help.propertybase.com/hc/en-us/articles/360003180752-WebToProspect-REST-API
I'm ...
0
votes
1
answer
67
views
Can't get hello world unit test for Apex REST working
I'm in a scratch org and created SalesRepAPI.apxc as follows:
@RestResource(urlMapping='/get_sales_rep/*')
global with sharing class SalesRepAPI {
@HttpGet
global static Id getSalesRep() {
...
0
votes
1
answer
314
views
How to Write a Trigger when you insert or update a Contact, its Parent account's description should be populated into the contact description?
I need to write a trigger for the following operation: when you insert or update a contact, its parent account's description should be populated into the contact description. I am unable to do this.
3
votes
1
answer
410
views
Expose public Webhook listener from Managed Package
Many external Services allow you to register publically reachable URLs that will be called with or without a Payload as an event mechanism between systems.
I want my Managed Package to exactly have (= ...
0
votes
0
answers
63
views
Can we add global method or rest endpoint in locked package patch version?
We can't add new components to the package while creating the patch version of locked package.
We have a requirement, where we need to add the global method or rest endpoint. Is it possible through ...
0
votes
1
answer
370
views
Record triggered flow after save get child records
My scenario
I have an apex class that extends RestResource.Base
In this class I insert both the parent and child record at the same time
List<SObject> recordsToInsert = new List<SObject>();...
1
vote
1
answer
298
views
Can't parse JSON properly - access to inner list values
for two days, i am trying to figure out parsing of following json.
[
{
"name": "Czech Republic",
"alpha2Code": "CZ",
"...
-1
votes
1
answer
90
views
Condition not checking after adding error condition in postman
I have created apex class to update existing records, and I am adding error code, but record is updating when I run it in postman. But if I miss any parameters, I have to show error which is given in ...
0
votes
1
answer
309
views
After Establishing connection from external system to Salesforce getting error
We have created a standard callout class to establish a connect between Salesforce to SMIT system, and then we have provided our Salesforce credentials (like clientid, client secret etc). They ...
0
votes
1
answer
624
views
Update record using HttpPut method only specific field
I am trying to create Callout class to allow external system to update records,like below
@RestResource(urlMapping='/OppleadUpdate/*')
global with sharing class test_Callout2 {
@HttpPut
global ...
0
votes
1
answer
487
views
Call Rest API from Apex REST Class
I know it's possible to make Apex class methods available as a REST service with annotations. I also know it's possible to make a call to an external web service from an Apex class. Can I combine the ...
-1
votes
1
answer
173
views
Can I add suffix in urlMapping for HttpPost in RestResource
I'm having an apex class like this:
@RestResource(urlMapping='/api/v1')
global without sharing class MyRestService {
@HttpGet
global static List<sObject> getDataById() {...}
@HttpPost
global ...
-2
votes
1
answer
566
views
How to Display custom error code and custom error message in catch block? [closed]
@RestResource(urlMapping='/AccountThrowErrorCode/')
global class AccountError {
@HttpPost
global static Account doPost(){
string jsonResponse='';
RestRequest request = ...
-1
votes
2
answers
1k
views
Disable "Generate new password and notify user immediately" checkbox while creating User via API
I have a usecase where I am creating new users via REST API. When we create a new user from UI then there is this checkbox Generate new password and notify user immediately which is selected by ...
0
votes
1
answer
238
views
Test code coverage not covering the for loop
EDIT:
My latest code with the new error, I used the code suggested by sfdcfox and here is what the error I'm seeing:
execution of BeforeInsert caused by: System.NullPointerException:
Attempt to de-...
1
vote
0
answers
132
views
Unable to Set Response Headers in Abstract or Extended Class
I am trying to set the Content-type header to application/json on REST response in apex and no matter where I set it, it always returns application/octetstream. I am using an abstract base class. When ...
2
votes
1
answer
793
views
File corrupted on sending data to create file via workbench using REST API
I am trying to create a file in in salesforce via workbench. The file is getting created although the file is corrupted. I feel there is some issue in binary data. What I am doing to get the binary ...
0
votes
1
answer
963
views
Apex Callout Issue - System.HttpResponse [Status=Moved Permanently, StatusCode=301]
I am trying to make a callout to an open public api. When I tested it on Postman, it is giving me the expected response. But when I tried it on the Apex class, the response is giving me the following ...
-1
votes
1
answer
2k
views
is it possible to add uri parameters on a http callout using named credentials?
Context: I have to call, from a source org, a HttpGet method from a target org.
This method will return a list of records that match a certain value on a field, which I have to send from my source org....
-3
votes
1
answer
1k
views
Consuming salesforce Rest API with out security token [closed]
I am exposing a API in salesforce which will be hit by an external c# application. I am enabled oAuth mechanism. Things are looking good but when the external end point needs to pass user id and ...
2
votes
1
answer
1k
views
How to generate and send a PDF via REST API Request
This is a follow-up new question to This SE
Is it possible to create a custom REST API Class to allow an oAuth connected app client to download a dynamically generated PDF visualforce page via REST ...
-2
votes
2
answers
3k
views
How to create endpoint url in salesforce org to use in rest resource [closed]
Rest Api. I wanna to create a link to be able to get api calls
@RestResource(urlMapping = '/GetByDate/*')
global class RetutnLeadsByDateRestResource {
@HttpPost
global static void ...