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
2 votes
1 answer
66 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/...
  • 551
0 votes
1 answer
27 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....
  • 329
0 votes
0 answers
76 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
96 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 ...
  • 526
1 vote
3 answers
260 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
76 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(...
  • 1,175
0 votes
1 answer
47 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
101 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
71 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", ...
  • 497
0 votes
1 answer
45 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
69 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
96 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
98 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
86 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 ...
  • 1,159
0 votes
1 answer
131 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
44 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() { ...
  • 1,167
0 votes
1 answer
244 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.
  • 63
3 votes
1 answer
210 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
34 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
175 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
207 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", "...
  • 29
-1 votes
1 answer
75 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
205 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
253 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
194 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 ...
  • 97
-1 votes
1 answer
66 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
290 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
-1 votes
2 answers
634 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 ...
  • 9
0 votes
1 answer
151 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-...
  • 6,834
1 vote
0 answers
80 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 ...
3 votes
1 answer
456 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 ...
  • 83
0 votes
1 answer
556 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
1k 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
805 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 ...
  • 79
2 votes
1 answer
838 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 ...
0 votes
0 answers
120 views

CSRF token for external system callout

I am new to salesforce development. I have a API consume apex class where I call an external system using GET method (Rest API) The external system doesn’t have any anti CSRF implementation Will ...
-2 votes
2 answers
1k 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 ...
1 vote
1 answer
2k views

How to get the number of objects I received in JSON response?

How can I count the number of objects I received in JSON response? In the below response I got two objects (id:1234, id:2345) and I want a variable that shows the total number of objects received in ...
  • 59
-2 votes
1 answer
42 views

Add two values that return from API

I'm going to be calling a REST endpoint to return back data for two datapoints into a lightning component in SF. This is only needed from a UI standpoint visually on the lightning component. This may ...
0 votes
1 answer
99 views

Is it possible to expose a webservice from lwc in Salesforce? [closed]

I want to make a REST api call to show notification or toast message in the lwc. I have tried with Platform Events and Change Data Capture. Is there any way to receive the REST API call in the lwc so ...
0 votes
1 answer
4k views

Apex REST API GET method with request body?

How do you do a HttpRequest for a GET method with a request body? For some reason this GET method is getting converted to POST and is not successful. This is working via postman. Http http = new Http(...
  • 444
0 votes
0 answers
816 views

Salesforce to Salesforce REST api integration to same org fails with 401 Unauthorized

The salesforce Field Service Developer Guide has this snippet of APEX designed to make a same-org REST call: String salesforceHost = System.Url.getSalesforceBaseURL().toExternalForm(); String url = ...
  • 509
1 vote
1 answer
1k views

what would be the best way to insert bulk data to a custom object

I need to make 2 calls per day to API Rest and process the data. I have used “apex scheduler” to automate the 2 calls a day, then call to my apex class where I have all the logic to call the ...
-1 votes
2 answers
320 views

Record is only update from API [closed]

The record which came from Rest API should only update from API, no user can update the record manually. for(Opportunity guestuser: trigger.new) { id currentuser = guestuser.CreatedById; ...
3 votes
1 answer
269 views

Check if apex is being run in Rest Resource

Is there a way to check if being run in RestResource Context? I have a script that posts messages to an endpoint but we can end up in an infinite loop scenario as they are now posting their comments ...
-1 votes
1 answer
243 views

System.TypeException: Invalid decimal in Rest Resource @HttpPost

I developed an Apex REST web service in Salesforce with the method 'POST' and i am trying to insert the string value in currency field of Product__c object, so when I try to hit the API im getting the ...
0 votes
1 answer
320 views

Help with TEST Class using @HttpGet [duplicate]

I have this simple little @HttpGet method. @HttpGet global static List<Case> getCases() { RestRequest req = RestContext.request; RestResponse res = RestContext.response; ...
1 vote
0 answers
223 views

Resubmit API Callout from Queueable method

I am working on an assignment where I need to process some subscribed events in Salesforce when a third party system publishes an event. The third party system publishes an event when there is a ...
0 votes
0 answers
314 views

How can Automated Process user get access to REST API class without having to change its Apex Class permissions in the profile?

We have a scenario where from a platform event handler (so user is Automated Process), we could be making a REST API callout to a class belonging to another managed package. Doing so leads to this ...
  • 2,539
-1 votes
1 answer
159 views

Most secure method of authentication for an API user? [closed]

We have a need for an external site to call services exposed from our Salesforce org via APEX REST. In previous projects I would leverage a connected app with username/password flow and create an API ...

1
2 3 4 5
12