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
1
vote
1answer
34 views

PDF file is getting corrupted when sending by HTTP callout to external system

on file upload below function is called in LWC. LWC Function uploadHelper() { this.file = this.filesUploaded[0]; this.fileReader = new FileReader(); this.fileReader.onloadend = (() =&...
1
vote
2answers
28 views

Query All Knowledge__kav records

I am stuck with weird situation. When I execute the following query SELECT Id, ... FROM Knowledge__kav Nothing is returned (0 records result) But when I execute the following query SELECT Id, ... ...
1
vote
2answers
50 views

HttpResponse[Status=BAD_REQUEST, StatusCode=400]

I'm trying to sending a field value to third part but here the issue is Suppose the filed is Name = "Test Account" here in this case call will be failed but for suppose Field Name is like Name = ...
0
votes
1answer
24 views

Auto Refresh Access Token

I have written this method to get accesstoken when I send Id & password given(Which I havent Hardcoded Below). I am saving my access token in custom setting and want it to expire, call this method ...
0
votes
0answers
21 views

Has anyone solved the error 415 (Unsupported Media Type) in salesforce?

Has anyone solved the error 415 (Unsupported Media Type) in salesforce ? I tried to upload a file to ContentVersion via rest api request but it 415 error will be returned by my org. Is there any ...
-2
votes
0answers
30 views

HTTP Error 400. The request is badly formed (Apex call to Sharepoint) [closed]

After getting access_token, i am trying to upload a static random file to Sharepoint public static String postFileonSharepoint(Map < String,Object > accessToken) { String folderName = '...
0
votes
0answers
28 views

Issue converting file object types to String format from an incoming OneDrive REST API call

I'm trying to pull a file object-type from O365 via the Graph API and I'm getting back a return-type that is pretty atypical to the normal JSON return format I'd expect to see. I'm not sure if it's ...
1
vote
1answer
56 views

Get the Info of a REST API Sender

Is there a way to get the Sender info in a Rest WebService? for example : Part A - Sender sends this JSON Via POST Request : Http httpProtocol = new Http(); HttpRequest request = new HttpRequest();...
0
votes
1answer
43 views

How do you create an endpoint in salesforce that accepts files (csv)?

I would like to create an apex service in salesforce that accepts csv files. Resolved this issue with the following: Created a public site which the FileUpload class is added. Since I need to create ...
0
votes
1answer
24 views

Simplifying REST API calls

I'm new to Java programming and I'm trying to reduce the number of REST API calls I make in my program to better organize it and I'm not sure how best to approach it if the simplest way is to have a ...
1
vote
0answers
26 views

Help writing Salefsorce Api call Test class

I have used some of the guides available like (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_testing_httpcalloutmock.htm), but still having trouble ...
0
votes
0answers
17 views

QueryMore (or similar functionality) for custom rest api

We are trying to implement a custom rest api for a custom object which has more than 2000 records. We are doing pagination based on CreatedDate of the records and display 200 records each page. We ...
1
vote
1answer
19 views

Using curl to retrieve data from Apex: Where to get security token?

curl -v https://login.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=<your_consumer_key>" -d "client_secret=<your_consumer_secret>" -d "username=<...
2
votes
1answer
137 views

Apex REST API - Unable to set StatusCode to 429

I am trying to set the status code to 429 for Too many request using the code below: if(Limits.getQueries() < Limits.getLimitQueries()){ upsert UpdateData; } ...
1
vote
1answer
31 views

Malformed JSON: Expected '{' at the beginning of object for the LIST

I am making an endpoint call and trying to extract the value from JSON.I am getting the parser error. What I am doing wrong here? Apex controller HttpRequest req = new HttpRequest(); req....
1
vote
1answer
86 views

Apex Rest - Api error handling HTTP status codes

I am trying to handle multiple error codes in my REST service. Can anyone guide me if I am doing this correctly. try { if(Limits.getDmlRows() < Limits.getLimitDmlRows()){ ...
0
votes
1answer
54 views

STATUS_CODE returned for the response: 403 STATUS_MESSAGE returned for the response: Forbidden

Can someone please guide me how to resolve the access forbidden 403 status code error ? What can i do to at least hit the end point? I am executing the code anonymously in developer console string ...
1
vote
1answer
16 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
1answer
39 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 ...
0
votes
1answer
41 views

Apex call-out 404 not found error on Developer console while it works perfectly when the request is sent through postman

This is the request, I've added the URL to named credentials. What am I doing wrong!! Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint('Callout:AppointmentTest/...
1
vote
0answers
80 views

First REST API Call for the day taking more than 40 seconds

We have exposed a custom rest webservice to perform dml operation on Case. We have a custom metadata where we fetch for a particular record based on the request parameter and populate the values for ...
0
votes
1answer
41 views

Rest Resources calling problem [closed]

I need to help about rest resources. We want to set a job that will come to salesforce and take data that we give by rest resources. However, the problem is that how to call apex rest service from ...
0
votes
1answer
135 views

How to append XML root element to an existing xml string

I have XML string like below in that I have to add root element and some attribute using apex. I was searching this for whole day but I din't get any key point. I saw there is some support for DOM and ...
0
votes
0answers
48 views

Salesforce Apex Error

Sync down of settings is failing in salesforce mobile native swift app.The error from salesforce is NSLocalizedFailureReason = APEX_ERROR Sync type:syncDown id:1 FAILED cause:Server call for sync ...
0
votes
0answers
55 views

Rest request for file upload in chunk around 8MB

I want to pass the list from helper class to apex class method but unable to pass. can anybody help over this. Below are the code of component and helper class declared in component class <...
0
votes
0answers
15 views

Salesforce REST API Call to an External API (IdentityServer3) Login Error

I have a project where I need to connect to an API to get data. I tested the API in postman and I'am able to get data, but when I try to connect from Salesforce I having a problem in authentication. ...
1
vote
0answers
30 views

Record Lock Issue for REST endpoint

I have built a REST endpoint, which writes data(Accounts) to Salesforce. Currently, for a single record, there could be multiple (20-30 times) upserts within 1-to-5 seconds. Behind the scenes, it's a ...
0
votes
1answer
29 views

WB REST API POST

I need connect an application with salesforce. This aplication will send data to the system, and salesforce work with them. In this case, in the third application, user choose products. When user ...
0
votes
1answer
48 views

Generate JWToken from salesforce using Consumer Secret

I am trying to connect to an API and based on their requirement, JWToken is required to make a call and the JWToken must be signed using the provided consumer secret. Now, they have a sample code in ...
0
votes
2answers
86 views

Call Salesforce API Rest with python

I'm try to call a REST web-service I made on Salesforce from a Python script @RestResource(urlMapping='/test_rest_api') global with sharing class Test_RestAPI { @HttpPost global static void ...
1
vote
1answer
22 views

Can I change the accepted Root element of ApexRest?

Possibly a bad question, I am exposing a simple ApexRest Class to accept post's from an external source. example bellow: @RestResource(urlMapping='/user_defined_type_example/*') global with sharing ...
2
votes
2answers
280 views

Variable is not visible

I have this variable which returns key from custom settings. below is the code related to this private static String AccLinks { get { if (Acclinks == null) { ...
1
vote
1answer
38 views

how to provide username and password in test method for REST API

apex.runtime.impl.ExecutionException: pad block corrupted if (req.headers.get('username') != null&&req.headers.get('password')!=null && Authorization.decrypt(req.headers.get('...
0
votes
0answers
34 views

Test class for RequestData class [duplicate]

@HttpPost global static List<HHSurvey> getHHSurveyList() { RestRequest req = RestContext.request; RequestData mRequestData = (RequestData)JSON.deserialize(req.requestBody.toString()...
0
votes
2answers
69 views

Test method for request in JSON Format

Malformed JSON: Expected '{' at the beginning of object @HttpPost global static Void doPost() { //Initailizing variables String respString =''; ...
0
votes
1answer
94 views

How to change UserServicePresence in Salesforce and How to get the list of Status shared to a profile?

I have a requirement to create a Global Quick Action that would display all the "Service Presence Status" available to a Live Agent and Change the status when he selects any of the status available. ...
1
vote
0answers
42 views

Calling Salesforce Rest Webservice url from vf controller

Hi I am trying to make a rest callout from controller and I am not been able to get response . I am using apex continution callout pattern for this to make call async. This is controller class ...
0
votes
0answers
55 views

Can I use @Httppost and @Httpput on the same method

I want to use 1 method regardless of whether the request is sent as a Post or Put (upsert). So, if the request has an Id field populated, it will update the record, if not it will insert. Can I just ...
0
votes
1answer
44 views

Salesforce Unauthenticated REST - HTTP 301

I followed this tutorial, http://www.wadewegner.com/2013/03/creating-anonymous-rest-apis-with-salesforce-com/ , to create a public rest service in a developer sandbox. If I run any of the following: ...
0
votes
1answer
19 views

Assign a record as a look up object before insertion

I am attempting to write an api endpoint meant to upload many objects of one type. This object, MyObject, contains a lookup field that looks up another MyObject record for translation reasons. ...
1
vote
0answers
76 views

Docusign Salesforce integration with webhook listener

We are using Docusign REST integration in our managed package, but right now it is not real time. we send the sign envelope request to Docusign and then do the continous polling for response of the ...
0
votes
0answers
19 views

TestClass for @HttpGet to find locations based on geocodes [duplicate]

I am new to Apex coding and with lot of struggle I wrote the below apex class to find locations based on a Geocode custom object records. Now, I am having difficulties to write a testclass for the ...
0
votes
0answers
118 views

Getting Bad request for Connected App

I am using Connected app to authorize the access token but I am getting bad request. here is my code. public static void test(){ String clientId = 'REDACTED'; String clientsecret = '...
0
votes
1answer
54 views

How to execute class or method after update external id from post callout

I have a custom object in Salesforce with a set of fields. Some of the fields I sent over by an invocable method which calls a future method to send the first set of fields to entity in an external ...
0
votes
0answers
36 views

How to retrieve files from an external server

I'm not at all that familiar with web service, but we do have this requirement in which, once a month, we need to retrieve some pdf files from a folder in an external server, and then attach them to ...
1
vote
1answer
333 views

Invalid character in identifier in Wrapper class

I am doing a rest call with the below endpoint string endPoint = 'https://test.salesforce.com/services/data/v43.0/query?q=SELECT+Name+,+RecordTypeId+,+Code__c+from+Account'; I have the below class ...
1
vote
0answers
27 views

Anyone had a problem with a REST service exposed on a Site after an instance refresh

I have a REST service that I have exposed via a Site called public. It has a URL like this: https://company.secure.force.com/public/services/apexrest/my_service This service is use to receive ...
2
votes
0answers
29 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 ...
0
votes
1answer
393 views

How to create JSON string for REST callout from Wrapper class

I have found a lot of different examples of this, but I'm still having troubles accomplishing this. Here is the webservice which is working: //WORKING Webservice in target org @RestResource(...
0
votes
1answer
55 views

Rest API Response - Break Address into multiple fields

I am working on an assignment where we enabled an external system to search for contacts in Salesforce based on lastName, firstName, BirthDate. I have developed a webservice which queries the Contact ...