New answers tagged

0

Use Queueable instead of @future. You're allowed one Queueable call per execute method of a Batchable, Schedulable, or Queueable class. Alternatively, you could store the records in a variable and make the callout during the next execute/finish method, but that's decidedly more complicated than it needs to be.


1

I had exactly the same error and the same scenario: worked in workbench did not work in Java. As suggested above, I removed the manual URL Encoding step. Java seems to be automatically encoding. Here's the final code that worked. response = client.send(HttpRequest.newBuilder() .uri(UriComponentsBuilder ...


0

You can go through this documentation: https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/routes.htm Which is the REST reference to most of Marketing Cloud API's it includes the endpoints for interaction with Contact Builder API and of course examples on how to send HTTP calls to that endpoints.


0

In the end the requirement was met by using the following code. I think what the problem is, is when you get a list of the Knowledge_kav object, there was a "wrapper" of attributes that the custom datatype did not take into account. (see picture) and here is the final code I used: @RestResource(urlMapping='/PublishedKBArticles/*') Global with Sharing ...


3

Change the class signature: public with sharing class APTS_UsageInput_InsertTempRecordsBatch implements Database.Batchable<APTS_UsageInputWrapper> Make sure you consistently apply "generics" in your Batchable implementation, as covered in the documentation: public Iterable<APTS_UsageInputWrapper> start(Database.BatchableContext context) and:...


0

I had the same problem and after a few days of trying to debug it I was able to get it to work. I also used the code above and it worked for me as well. My solution was to create a new API Package under my Parent Business Unit and it worked immediately. The API Package I was originally working with was in a non-parent Business Unit even though I gave the ...


2

Looks like you may use Salesforce Event Monitoring feature, for your use case the REST API Event Type would be the one you'll be interested in.


4

There is a permission now that will allow you to access custom Apex REST services while not being able to access the standard REST API:


0

PATCH seems no longer supported. A work around is a POST method with a parameter : _HttpMethod=PATCH So It becomes : https://orga--sandbox.my.salesforce.com/services/data/v47.0/sobjects/Account/{id}?_HttpMethod=PATCH In the Body : { "AdCloud_PartnerID__c":"5400" } Please, upvote is it works for you.


1

Composite REST resource would have been our suggestion but it has a limit of 25 sub-requests, same as Batch. A better out of the box solution is describeSObjects() in SOAP API: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:partner.soap.sforce.com"> <soapenv:Header> ... </soapenv:Header>...


0

There is a Batch Api that can get upto 25 requests in one go. POST to "https://{YOUR_INSTANCE}.salesforce.com/services/data/v{API_VERSION}/composite/batch" //Headers: { "Content-Type": "application/json" } //Body: { "batchRequests": [ { method: "GET", url: "v{VERSION}/sobjects/{SOBJECT_NAME}/describe" }, ...


0

The Chatter API rate limits are distinct from the overall API call limits, and note that it is scoped to the user: For applications using a session ID from Salesforce, the rate limit is per user, per hour—there isn't a separate bucket for applications. All applications the user accesses with a session ID use this general quota. To take advantage of the ...


0

Here is a sample of a record update: PATCH /services/data/v47.0/sobjects/Account/001XXXXXXXXXXXX HTTP/1.1 Host: myorg-dev-ed.my.salesforce.com Authorization: Bearer 00DXXXXXXXX Content-Type: application/json { "BillingCity" : "San Francisco" }


3

This guard: if(!Test.isRunningTest()){ HttpResponse res = http.send(req); } and the use of Test.setMock(HttpCalloutMock.class, new FindAnApprenticeshipCalloutsMock()); are mutually incompatible. Your Mock class will never be called if you gate the HTTP call in your production code; remove the gate if you plan to use a Mock. ...


2

You seem to be confusing classes with methods. QueueableFindAnApprenticeship is a class, and you defined it like this: Public class QueueableFindAnApprenticeship... you cannot do HttpResponse response = FindAnApprenticeship.QueueableFindAnApprenticeship(); Instead, you can do FindAnApprenticeship.QueueableFindAnApprenticeship myClass = new ...


0

I have figured this out. Posting answer hoping it would help others. var jsforce = require('jsforce'); var conn = new jsforce.Connection({ // you can change loginUrl to connect to sandbox or prerelease env. loginUrl : 'https://test.salesforce.com' }); var _request = { url: '/services/data/v45.0/limits/recordCount?sObjects=Account,User', method: '...


3

You cannot directly create a ContentDocument. Instead, you must upload a ContentVersion. The parent ContentDocument will be created for you automatically. To link the file to an sObject, either set the FirstPublishLocationId field on the ContentVersion to the target record's Id, or query for the ContentDocumentId after insertion (it will be populated by the ...


2

Querying A Record To update a record, you must first have a copy of a record in memory. This means you need a CampaignMember object to update: CampaignMember queriedCampaign = [SELECT ID FROM CampaignMember WHERE CampaignID = :campId AND Email = :email LIMIT 1]; Assignment In general, you declare and assign values in the form of: DataType variableName [=...


0

I faced the same issue but it didn't work with changing the password. The reason is I was using Mutual TLS enforced. For this use case the request should use port 8443 explicitly. curl -v --cacert cacert.crt --cert cert.pem --key private.key -X POST https://mydomain.my.salesforce.com:8443/services/data/v47.0/sobjects/Case


1

The problem is, you're providing the wrong URIs, which is why Salesforce "Can't access the resource". You were probably looking at this page, and saw "/vXX.X/composite/sobjects". and thought your Batch request URIs were supposed to have "/composite/" in them - they're not. If you change your URIs to "/v47.0/sobjects/OpportunityLineItem" (as shown on this ...


0

I don't see a use case for the Composite API here at all. The Composite API allows you to Execute[..] a series of REST API requests in a single call. You can use the output of one request as the input to a subsequent request. The response bodies and HTTP statuses of the requests are returned in a single response body. The entire request counts as a ...


0

Only Address and SubscriberKey are required, the rest go under SubscriberAttributes. The SubscriberAttributes node should not include the Email Address or Subscriber Key. { "To": { "Address": "aspriggs@example.com", "SubscriberKey": "aspriggs@example.com", "ContactAttributes": { "SubscriberAttributes": { ...


0

I think that here you can use a HTTP Mock Factory to handle different status codes. Let's say we have this call out: public class ExternalSearch { public class ExternalSearchException extends Exception{} public static String googleIt(String query) { Http h = new Http(); HttpRequest req = new HttpRequest(); req.setEndpoint('https://www.google....


0

You should be able to pull this info in the REST API with the normal sobjects/describe endpoint. You do need to check what your actual API name is for your Knowledge object as it may be set differently. To do this, go to Setup --> Object Manager. Find Knowledge and see what the API name is. Use this value in the below: /services/data/v47.0/sobjects/...


1

Try removing the assetType object from your payload. It is unnecessary and cannot be written to in update assetType is there to define what type of item it is. (E.g. is it an image? An email? Etc) which is not necessary when updating as all this is already done via the existing asset. This info is collected via the asset Id in the url. Now it is tossing ...


0

ContactID is not available through the SDK. Please open a voice of customer request for this feature and, in the interim, you can request the appropriate privacy mode through your account executive. All devices tied together via Contact Key will be notified and respect the privacy settings indicated by the server-side contact.


2

Adding here as I spent a few hours trying to figure this same issue out last night. As this answer states, you do need to set up the send definition using REST API. You cannot use the UI to set up the send definition for transaction API driven emails. It's called out here: https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/...


1

The external system should listen for platform events using CometD (or you can use the EMP Connector: an open-source, community-supported tool that implements all the details of connecting to CometD and listening on a channel). Salesforce has a guide on how to do this. Salesforce sends platform events to CometD clients sequentially in the order they’re ...


0

Adobe Connect has a rich API -- why not exploit it? As far as I can see, it is a web services API (not REST API) so you'll need to use these Salesforce resources to help you: Apex SOAP Callouts - an Apex solution Salesforce Outbound Messaging via Workflow rules and Outbound Message Actions Help There are also middleware solutions like Mulesoft, Boomi, ...


2

Unfortunately, SOQL does not have functionality like this. You can find the overall SUM() of a field but not in a running total. Here is a link to the available SOQL Aggregate Functions: https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_agg_functions.htm I believe to achieve this in Salesforce, you'd ...


0

This isn't concrete evidence, but I'd suggest creating a case with Salesforce support to confirm it. My initial testing leads to the same results you're noticing. There's no explicit mention that the external Id field can be used in Traverse Relationships with Friendly URLs (granted, there's no mention it cannot) and that seems important given how they do ...


0

I went to the connected app. Clicked on edit. In API (Enable OAuth Settings), checked Enable OAuth Settings: Used https://login.salesforce.com Callback URL. Added Full access (full) in Selected OAuth Scopes. Now I am able to see the Consumer Key and Consumer Secret:


3

That isn't a valid URL. Curly braces need to be percent-encoded when they appear in a URL, as other invalid and/or "unwise" characters as defined by the RFC. See When, if ever, should characters like { and } (curly braces) be percent-encoded in URLs? . Replace the bracketed segment in your URL with %7B7c2b1ab5-40805b81c898%7D.


1

You should put ' ', but you don't need to escape them try that one https://{myWorkplaceDomainUsed}--sandbox.cs67.my.salesforce.com/services/data/v42.0/query/?q=select+Id+from+Contact+where+Email='apple+super@gmail.com'. If you want IN you can use it like this https://{myWorkplaceDomainUsed}--sandbox.cs67.my.salesforce.com/services/data/v42.0/query/?q=select+...


Top 50 recent answers are included