Questions tagged [restresource]
The restresource tag has no usage guidance.
81
questions
1
vote
0
answers
21
views
REST resource Unicode characters not working (form data)
I'm currently developing a Rest Resource that will be able to handle post method into Salesforce.
The request that I get is in form-data(!!!).
It contains Hebrew characters translated into Unicode
(i....
-3
votes
1
answer
23
views
Test Class for RestResource gives "Methods defined as TestMethod do not support Web service callouts" error [duplicate]
Looking for some help here. I'm trying to write a Test Class for a RestResource I defined but am receiving the above Test Class failure. I was under the impression that you didn't need to define a ...
0
votes
1
answer
34
views
How do I convert a ContentVersion record to JSON to pass via API?
I need to share files attached to an account externally via API to another Salesforce org (to recreate the files there).
In order to do this I'm trying to create a JSON file to contain the file/s ...
3
votes
1
answer
187
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 ...
0
votes
1
answer
25
views
Apex Unit Test for Rest Resource calls wrong class
I have 2 RestResource classes:
@RestResource(urlMapping='/Catcher/*')
global Without Sharing class vecCatcher {
@HttpGet
global static void httpGet() {
...
}
}
and
@RestResource(...
0
votes
0
answers
52
views
"You have uncommited work pending" when there's no obvious DML?
I have a RestResource which is running some callouts, as well as running some DML (after the callouts).
I'm recieving this error: You have uncommited work pending. Please commit or rollback before ...
0
votes
1
answer
28
views
Is that we can send the multipart/form-data till 2GB by using rest api in apex
Is that multipart message is available in RestAPI in Apex 2021 to send the large files(till 2GB) from source org to target org??
2
votes
1
answer
408
views
Why am I getting "Service not found error" when trying to access a @RestResource when it is exists?
I have a rest class with a @RestResource annotation and a method with @HttpPost annotation. Something like -
(urlMapping='/abc/contractors')
class ContractorInfoWebService {
@HttpPost
global ...
-1
votes
1
answer
71
views
Salesforce RestResource GET API is unable to identify special characters passed in query string
I have created a RestResource API class with GET method. It is supposed to accept the email passed as an input via the query string, and perfom logic based on that email received.
It all worked fine ...
1
vote
1
answer
69
views
Is there a way to check @RestResource usage frequency?
Can you please tell me, if there is a way to check @RestResource usage frequency?
Short summary: I have a legacy @RestResource which is supposedly not used by anyone. I want to check that.
I have ...
0
votes
1
answer
89
views
Is multipart/form-data available for apex @RestResource classes
I have a class that retrieves a file in binary code from an external webservice call to our Salesforce and generates a file but now they want to change it to multipart/form-data.
I've been reading the ...
4
votes
1
answer
289
views
API login after MFA enforcement
With the enforcement of MFA coming next year, I've started to test an API I wrote for a client that allows their website to talk to Salesforce. It's working fine right now, but if I enable High ...
0
votes
1
answer
381
views
ERR_ABORTED 401 (Unauthorized) in LWC
I am working on the Salesforce pilot feature where I can't call @AuraEnabled methods from LWC. As an alternative to this, I have created a rest resource and I am calling the same rest resource to get ...
0
votes
2
answers
898
views
CORS issue in LWC
I am testing on Field Service Lightning mobile app LWC pilot feature. Here apex is not supported in Field service mobile with LWC.
So, I am trying to make a SF rest resource callout, to get the ...
2
votes
1
answer
117
views
Apex @RestResource returning result inner class exposes private attributes
Any simple @RestResource may return results in the form of an instance of an inner class.
I expect any private attribute of the inner class to stay exposed only to the inner class, thus not be ...
0
votes
0
answers
23
views
RestResource Get URL [duplicate]
I have a Rest Web Service class that exposing Get Function.
I am trying to get the entire URL of the request to save it in logs.
According to the Salesforce Documentation I could get it, without ...
1
vote
1
answer
151
views
Allow guest profile to update opportunity line Item
I am trying to setup a web hook to use along side PandaDoc to update opportunity line items once approved but the query on web hook when ran on a guest profile does not return a line item. I can run ...
0
votes
1
answer
204
views
How can I call a RestResource through a Community site?
I have a RestResource hosted at /services/apexrest/MyApi. I know that VisualForce pages have an alternative URL through the Community site e.g. /sfsites/c/apex/MyVisualForcePage. Does the same apply ...
0
votes
1
answer
57
views
Time delay @future method - need delay for recurring batch process to complete
I have the following requirement and am looking for advice for the best way to process it.
We have multiple orgs linked to each other via S2S, with batch jobs running every 10min to pass updates ...
0
votes
1
answer
759
views
We added the header Access-Control-Allow-Credentials to true
We load JS code by creating a script tag with dynamic src endpoint and append the script element into the page our src will call resource apex class (@RestResource)
I know that Community domain is ...
0
votes
1
answer
52
views
How to access custom REST controller in managed package via Site [duplicate]
I had a custom Apex REST controller which was made available by a Site
https://xxx.umx.force.com/site-name/services/apexrest/urlMapping
But now I've added the Apex class into a managed package, I ...
0
votes
1
answer
757
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 ...
1
vote
1
answer
147
views
Why isUpdateable() is not working for non required fields in RestResource class?
I want to update two fields in a custom object from a RestResource class. This is the code I used:
@RestResource(urlMapping='/AllHistory/*')
global class SampleClass{
@HttpPut
global static ...
1
vote
1
answer
959
views
Callout to other Salesforce org using Named Credential - which Authentication option should I use?
I have 2 Salesforce orgs (with identical code) - a hub and a client. I need to pass data from the hub to the client. Using S2S is fine for normal data, but when it comes to files (eg pdf) we can't use ...
0
votes
0
answers
49
views
Is there Salesforce documentation on RestResource Object?
I'm following a design pattern set by one of our devs.
RestResource.RequestBody requestBody = RestResource.getRequestBody();
I'm trying to find documentation on this object, but I can't seem to ...
1
vote
1
answer
77
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": {
&...
2
votes
1
answer
342
views
Improve performance of a rest resource
I have a rest resource which fetches more than 10000 records. iterates the list using foreach and adds each record to a custom wrapper class list and finally returns the custom wrapper list as ...
1
vote
1
answer
71
views
Cannot test my own REST API from a beta managed package
I developed a REST API for my managed package which works correctly when tested for development in my scratch org but also as a released managed package.
Recently I made minor changes to it - like ...
7
votes
1
answer
418
views
Good way to offer both LWCs and a REST API in the same code?
We are building a product that will make use of multiple Lightning Web Components (LWCs), and some of those will make use of @AuraEnabled Apex methods. We also plan to provide an API that non-LWC UI ...
0
votes
2
answers
478
views
Apply pagination in Rest Resource
I have rest resource exposed to a external system. It is a simple rest api where i get a single parameter from the URL and query a custom object based on that param and return the results in a custom ...
0
votes
1
answer
126
views
RestResource JSON response is adding \"
I have some code where I am building a JSON response. My JSON looks like this
String jsonString = '';
jsonString += '{"Order":{';
// order fields
jsonString += '"...
2
votes
1
answer
46
views
Get nested Json restresource
I have the following json Response I get through a webhook with jira and a @restresource apex class.
{
"timestamp": 1572538898517,
"webhookEvent": "jira:issue_updated",
"issue_event_type_name":...
0
votes
0
answers
259
views
How to access the REST API with the user with Permission 'Is Single Sign-On Enabled' is enabled
I have created one RestResourc to give the ability to the external system to attach the Report to Asset in Salesforce. Now the problem I am facing is the user which I am using for Authentication ...
0
votes
1
answer
80
views
APEX test script to web server with a static time stamp doget cakk and HttpGet
New to writing test scripts. Looking for help in error in Unexpected token 'Lead' for my test code. I have a static field that pulls off time stamp to only pull data after a certain time. I am ...
1
vote
1
answer
124
views
Usage of Connected App in terms of exposing a RestResource API for consumption?
I know I have done it before, but I am lost this time around. Previously, I have created Connected Apps for implementation of Oauth 2.0 authentication process with Salesforce. But, this environment is ...
1
vote
1
answer
265
views
How can I disable my existing Apex REST Webservice in production?
I have an existing Apex REST Webservice configured in production for consumption by a partner for Lead creation.
However, we are not working with that partner anymore and hence want to disable this ...
2
votes
2
answers
441
views
WebService Post Rest API is Receiving as GET
I wrote a web service using @RestResource With both Get and Post methods.
When I try to send a request via workbench - everything works great,
but when I try to send a post request using other ...
0
votes
2
answers
456
views
Username Password Auth Flow returning different response than expected
I'm trying to get the access token using Salesforce Username/Password OAuth flow. I have created a connected app, provided full access in the Oauth scopes and pre-authorized System Admin profile users....
0
votes
1
answer
605
views
How to return response to a Shopify Webhook?
I have a Salesforce site which is used as a rest resource for a Shopify Webhook for new Order Creation.
When a new order is created in Shopify it hits the Url provided by us and expects a "200 OK" in ...
2
votes
1
answer
34
views
RestResource being Triggered upon Viewing a Record
Overview - i recently was assigned to take over a project which was started by an outside consultant. I am unfamiliar with RestResources which is what this project was built on. MY ISSUE:I need to get ...
1
vote
1
answer
2k
views
Is there a better rest endpoint for downloading file contents?
I'm trying to use https://[domain]/sfc/servlet.shepherd/version/download/ to download files (lightning files not attachments) from salesforce and it works sometimes and I can get it to work in postman ...
0
votes
1
answer
57
views
the vf page not dispaying the API value this is my code can any one help me out this
apex class:
public with sharing class AccountWeatherController {
public String response { get; set; }
public String city {get;set;}
public String temp {get;set;}
public String ...
2
votes
0
answers
70
views
Is there a way to specify an API version of a call to @RestResource?
I would like to specify an API version when I call a @RestResource via an API. Is that possible?
Why
For some reason, our Spring '19 sandbox is having a weird issue, and I'd like to fix this before ...
1
vote
1
answer
2k
views
Rest Resource URL mapping in workbench
i have written a rest web service class and mapped the resource as '/Accounts/*/contacts'. where * stands for Accountid.
I am trying to do a POST call from workbench and having issue writing server ...
6
votes
2
answers
569
views
Silence the AvoidGlobalModifier warning in @RestResource Apex controller
I have a simple Apex Controller annotated with @RestResource. According to the documentation, this must be declared global, but the static analysis complains due to the AvoidGlobalModifier PMD rule.
...
1
vote
2
answers
850
views
RestResource HttpPost - 401 Unauthorized - INVALID_SESSION_ID
I am attempting to call a RestResource HttpPost method, but receive an INVALID_SESSION_ID response.
[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]
Apex Code (version 43):...
6
votes
1
answer
10k
views
Posting a JSON to REST resource in Salesforce
Before I go ahead and describe my issue, I have looked at a resolution as described below and does not seem to help in my case.
is that possible to pass(POST) below JSON to REST endpoint?
So, I have ...
2
votes
1
answer
172
views
Why am I not able to parse valid XML straight from the Salesforce Documentation, but JSON works fine?
On this particular page:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_rest_methods.htm
About halfway down, you'll see a method which I have included in my class
@...
0
votes
1
answer
452
views
CRUD FLS issue to edit task access for site guest user
I am applying CRUD FLS on task object fields and also I have provided read and edit access to task for site user profile. Even checked with sharing settings as 'Controlled by parent'.
But still when ...
6
votes
1
answer
121
views
Strip Authorisation header from inbound REST Request
I'm integrating with a 3rd party data provider.
The way their platform works is you must provide an endpoint to which they periodically send REST requests to with updated data etc.
They happen to ...