New answers tagged

2

Overall advice: keep it simple. Every time you make the solution more complex “unnecessarily”, you are also likely to leave a hole. This is especially true when it comes to security, there are lots of nuances. Encryption/Decryption What you do here depends on the REST service you're calling. The lowest common denominator and a best practice is to always ...


0

The problem is in the pkcs8 variable in JWT class, it is null, because the JWT class is called from future context and it isn't set to any value. Therefore, the method Blob privateKey = EncodingUtil.base64Decode(pkcs8); gets null as an argument which is unacceptable. The same relates to cert variable.


1

I can't find this in the documentation, but I tested it in Workbench, and it is just 1 API call per transaction, for up to 200 records.


0

You would work from the sample for: Email - Update Message Definition.


0

This might not be the answer you are looking for but will get there eventually. Why do you think giving Salesforce community user API access is a good idea? giving API access means your community users can login and use complicated tools like DATA-Loader and if there is a malice in one of them you are just opening up the gate to hell by giving API Access. ...


0

Content-Type needs to be multipart/form-data; there are also other requirements (see docs). This is difficult to do in Apex but possible. You should vote up this idea.


2

Think of community as a sandbox within a larger SF org. If you authenticate to a community, your security context is restricted to this sandbox. You can do things within that sandbox but not outside of it. When you use SFDX to authenticate against the org, your security context is at the org level, thus the auth token (session id...) works for both community ...


0

Ideally querying (pk) index field should not this much of time. To idenfity the where slowness is you do following things. On high level slowness can be at 3 level A. Client side - as you are using curl, there is very low chance this can be valid reason. B. Network - its possible. check how is your network speed when you are running these test C. Server - ...


2

Your mock is returning a single object (that starts with a {) rather than an array that starts with a [) that the callout class expects. Change the mock to e.g.: res.setBody('[{"MasterId ... }]'); which is an array containing one object. See e.g. http://json.org/ for more detail on JSON objects and arrays.


0

I believe you will need to authenticate into the desired Business Unit to generate an access token before processing your request. You'll just need to specify the account_id when making that auth token call. Here's a link to the documentation on that.


3

It is not in your Asset API request that you specify it. When your integration authenticates, it does so on behalf of a user with an MID. If you want to push to a different MID you need to re-auth under the other account. If you need to push to the two at the same time, you will need to maintain two different sessions.


1

The REST and SOAP APIs do not have full parity at this stage. ( Source: https://developer.salesforce.com/docs/atlas.en-us.mc-apis.meta/mc-apis/index-api.htm ). Data Extensions go as "Most other email activities", filed under SOAP. (You can only deduce this as they aren't listed as one of the positive options for either REST or SOAP...) So, unfortunately, ...


0

Have you taken a look at the Streaming API? It let's you stream events and therefore react to the data updates.


0

File upload is not officially supported by the Live Agent REST API. This is currently a limitation acknowledged by Salesforce support as of 3rd July 2019. You can still make it work, however it carries the risk of using an undocumented functionality. The request to the upload servlet should be modeled based on the following CURL command: curl "https://cs6....


0

Not sure if it fits your case or violates performance/security constraints (I'm no developer) but one approach that comes to mind is the following: Create a Marketing Cloud cloud page. Push your request data to the cloud page Read and transform the POST data on the cloud page Use SSJS API functions to interact with the Marketing Cloud REST API. ...


-1

I feel that you may have a little confusion about CORS & REST. In fact, you know we have many tools to test SOAP & REST requests, such as SoapUI, Postman... When you use one of them to do a test, of cause you needn't write any backend codes. You just need configuring some parameters and send them out for testing and the tools will return a response ...


1

You can review sent Triggered Send emails from the Marketing Cloud interface. Select Tracking > Sends from the navigation menu in Email Studio, then expand the 'My Tracking' folder in the left pane and select 'Triggered Sends'.


1

I worked out the solution after tinkering with the API call myself, you need to not reference contacts and reference the /row route followed by the row ID of the data extension to obtain the relevant data for the email where many contacts are present in the one data extension. https://www.exacttargetapis.com/guide/v1/emails/{EMAIL_ID}/dataExtension/key:{...


0

Two options:- 1 Nest multiple REST classes within a single wrapper class - can use distinct URLs 2 As above include within the parameters of the input a process identifier that routes the processing to the required option. Personally if I have dozens of web services to code for many different purposes I would opt for SOAP and use helpful method names.... ...


1

I use this format POST /messaging/v1/messageDefinitionSends/key:External_Key/send Where External_Key is the one from Your triggered send. Then, I'm using a sendable Data Extension. If You try to search it with the data related the request, mostly creating a filter, You can find the request. That doesn't mean the email was sent. You have two methods to ...


0

I managed to fix this by removing the DataExtension attribute from the Triggered Send Definition. In fact, I don't need this attribute, because all that matters is the Subscriber Key. If I have some Subscriber Attributes to specify, I can still copy the data from my Data Extension Row, without forcibly specifying which Data Extension it belongs to


3

The only thing you need to do is retrieving body of the post request, this can be done like in the example below: @HttpPost global static void processPost() { Map<String, Object> requestBody = (Map<String, Object>) JSON.deserializeUntyped(RestContext.request.requestBody.toString()); //do something with the resulting map - this is the ...


1

This has to do with your payload - getting details of a job (what you're attempting with operation query) should go against /async/<api_version>/job/jobId. It should have an empty request body. The /job resource is for creating jobs (operation: insert)


1

Issue: customer.io allows you to add a webhook that can call to a Salesforce REST API with an oAuth access token configured in their web UI. Access tokens expire. They don't provide an API for updating the webhook definition (to update the access token) nor do they implement a refresh token flow which would automagically update the access token. As a ...


-2

I don't think you can directly pass the external Id in the payload. Try something like this: { "FirstName" : "John", "LastName" : "Doe", "RecordTypeId" : "0120C0000006eySWER", "Contacts" : {"Profile_UUID__pc" : "112233"}, "Email" : "john.doe@mail.com" }


0

Visualforce remoting, remoteFunction, are used to call Apex on the Platform. If you wanna call any third party site from javascript then do a normal AJAX call. Also, as it will be a cross-origin request from javascript so make sure the end-server supports CORS from SF domain.


2

SOAP won't be deprecated in the near future (presumably); if it were, we'd be notified in advance. The primary benefit is upload speed/reduced bandwidth. As a secondary consideration, if you're already in a REST project, you don't need to switch to SOAP just to perform deployments. Also, technically speaking, certain languages excel at either XML or JSON, ...


1

An authorization code is a credential representing the resource owner's authorization (to access its protected resources) used by the client to obtain an access token. It's an intermediary construct in the authorization flow sequence, you don't need to "manage" it in your application. As you correctly pointed out, it only comes in play with specific oAuth ...


0

https://test.salesforce.com/... is the right way to go for sandboxes. From the doc Instead of login.salesforce.com, customers can also use the My Domain, community, or test.salesforce.com (sandbox) domains in these endpoints. (Admittedly, it's a very brief doc note)


5

You cannot create a triggered send definition with the UI if you are using the Transactional Messaging API. You need to create your definition via the REST API in order for this to work.


2

For sandboxes two URL types can be used: Generic URL like https://test.salesforce.com/services/oauth2/token Specific Classic Domain URL like https://domain--full.cs100.salesforce.com/services/oauth2/token Lightning domain URL cannot be used. Classic domain URL changes every refresh since Sandbox might migrate to another instance, so it is better to use ...


2

A couple possible issues: 1) Does the Installed Package whose credentials you are using to retrieve your auth token have permission to emails? Read, write, send, all? As a note, I have seen in the past that updating permissions on Installed Packages does not actually propagate the permissions -- I believe this has been fixed, but it may be worth trying to ...


6

429 Too Many Requests is not an appropriate status to return from Apex that is processing a REST request, and so presumably that's why the server prevents you from doing so. The relevent RFC indicates that this response is for rate-limiting, ie, the number of HTTP requests received from a single client in a given amount of time: The 429 status code ...


2

SOQL does not returns field with null values when serialized directly. Easiest work around is to copy the field values to a new sObject. Example: Account account = [SELECT Id, Name, BillingCity FROM Account WHERE Name = 'Test Account']; Account newAccount = new Account( Id = account.Id, Name = account.Name, BillingCity = account.BillingCity ); /...


2

Your question seems to me to approach this issue backwards. You have in hand a list of HTTP status codes and are trying to find Apex exceptions that correspond to ("handle") them. But there are scores of HTTP status codes, and most of them are either (a) completely irrelevant to this code or (b) handled by the underlying Salesforce application. For example,...


-1

You need to correct your Authorization value like :- Bearer 00D3F000000 ...Provide space after "Bearer" then your access_token


1

Problem is with domain name used in url. :| Using the domain as in "Setup > My Domain" fixed the issue. I have used : https://testOrg.lightning.force.com/ (Did not work) Supposed to be: https://testOrg.my.salesforce.com/ (Worked) Thanks.


0

Resolved the issue.. The webservice my Apex code was trying to invoke is hosted on a server that can't be accessed from outside the organization. The firewalls restrict API calls coming from outside of the network. As as result Salesforce (which is on the cloud) was unable to access that webservice. Resolution: We migrated the web service to an environment ...


Top 50 recent answers are included