Skip to main content
10 votes

How to Session ID for a curl request?

I tried Ashwani's trick. It looks like security removes session id's from logs now. Here's a quick workaround. SYSTEM.DEBUG('Session Id : ' +Userinfo.getSessionId().reverse()) Then you can just grab ...
Kody's user avatar
  • 101
8 votes
Accepted

Connected App built in SANDBOX has access to PROD

This is a feature of OAuth, and is working as designed. A connected app clientId and secret can be used to connect to any org provided you go through oauth flow and enter username and password (or ...
Mohith Shrivastava's user avatar
7 votes

Rendering Email Thumbnail in Hub

The route listed in this question is unsupported. It should not be used in production environments. This route may stop working or become unavailable at any time with no notice.
FreeRangeHotDogs's user avatar
5 votes
Accepted

Salesforce authentication failure

The critical note from OAuth 2.0 Username-Password Flow for Special Scenarios says: When using the username-password flow with an API, create a field in the username and password login screen where ...
David Reed's user avatar
  • 93.4k
4 votes
Accepted

How to pass API endpoint URL containing \ to

I strongly suspect that something is going sideways because you're not properly escaping the non-safe URL characters (like \ and [); in a URL, they must be in a certain style known as "percent ...
sfdcfox's user avatar
  • 500k
4 votes

Help converting this cUrl to Apex?

It'd probably be best if you started as a String array: // ... String[] payloadParts = new String[0]; String[] toBindings = new String[] { '{"address": "+18005551212", "binding_type": "sms"}', '{"...
sfdcfox's user avatar
  • 500k
3 votes

Persistant INVALID_AUTH_HEADER with curl on macos

I finally found that the problem is related to Bash which interprets the '!' char in a specific way (command history if I understood well). I found about the same question on the Unix stackexchange ...
fredbe's user avatar
  • 135
3 votes
Accepted

Using curl to make a REST API call

Setting +H before the command should fix it.
Bryan Anderson's user avatar
3 votes

Can I get a refresh_token using cURL from the command line, or in Salesforce.com itself?

I think you'll be better off using JWT for oAuth. It's more predictable behavior. Here is a PHP github library that I've used that has a lot of the code - https://github.com/adhocore/php-jwt To ...
PartOfTheOhana's user avatar
3 votes
Accepted

JSON with backslash for CURL. Not able to generate Apex request class

When you invoke curl from the command line, you have to escape any double quotes that you include within any quoted string. The escaped quotes are interpreted by your shell (probably bash), not by ...
David Reed's user avatar
  • 93.4k
3 votes
Accepted

curl post request to marketingcloud REST API is returning InvalidOrMissingTo

I was using the incorrect Content-type ... It should be application/json
mario ruiz's user avatar
3 votes
Accepted

Calling a flow through REST api returns "http body is required" error

flow expect input parameters while calling through API so you need to pass blank input array if you are not passing any value. Update your body with following json { "inputs": [ {} ] } So your ...
Himanshu's user avatar
  • 10.5k
2 votes
Accepted

cURL Error 51 when Posting to Force.com

Is there any other way to fix this? In theory, yes. You can go to Setup > Security Controls > Certificate and Key Management, upload some new certificates, and assign them to your Site via custom ...
sfdcfox's user avatar
  • 500k
2 votes

salesforce rest api invalid session id error when using access token

I do not know php , but essentially there are 2 parts that your program need to cater for , curl command shown below. First, get the session id, then use session id in header to preform the action you ...
Clint D'Silva's user avatar
2 votes
Accepted

Can I Upload Remote PDF File to Account via PHP?

I am hoping that you are using Force.com PHP SDK. You can directly call attachment SOAP API with following code. $url = "$instance_url/services/data/v20.0/sobjects/Attachment/"; $...
Himanshu's user avatar
  • 10.5k
2 votes

Help converting this cUrl to Apex?

A request bin service can be helpful in showing exactly what curl generates for the outbound body content. The curl manpage is also helpful: --data-urlencode (HTTP) This posts data, similar to the ...
David Reed's user avatar
  • 93.4k
2 votes
Accepted

Convert cUrl to rest in Apex?

The following api can get you customer subscription HttpRequest req1 = new HttpRequest(); req1.setMethod('GET'); String customerId='cus_HJ3f4cSLOxY9a6'; string endpoint='https://api.stripe.com/v1/...
User6670's user avatar
  • 3,035
1 vote
Accepted

windows curl authentication error

solution: https://stackoverflow.com/questions/10060093/special-characters-like-and-in-curl-post-data replace -d "password=<your_password_and_security_token>" with --data-urlencode &...
Luis Aguiar's user avatar
1 vote
Accepted

Download Attachment using php is not working for xlsm files

This got worked by removing the CURLOPT_HEADER option. curl_setopt($ch, CURLOPT_HEADER, 1); //remove
Mûhámmàd Yäsår K's user avatar
1 vote

SFMC API call to 3rd party when unsubscribing

You'll have to use SOAP API and Update a Subscriber using the Update Method. Create and Install a package to get your Client Id and Client Secret. Set the appropriate permissions. Find your ...
Jackson Chen's user avatar
  • 4,725
1 vote
Accepted

Trying to run a sql activity thourgh a curl SOAP request - SoapAction incorrect?

It's a tag value which should be "Start" and your have it: <Action>Start</Action>. The SOAPAction is a different one. It's a header. Try using a header like this: SOAPAction: Perform. ...
nchursin's user avatar
  • 1,001
1 vote

BULK API cURL commands to GET 100k records from Account

According to the docs here, there is a way to do this without the new Bulk API 2.0. I've verified this method will eventually return all results 2000 records at a time. If the initial query ...
Jomtung's user avatar
  • 376
1 vote

How to create a business account with the REST API

Ok so this is what ended up being the issue: 1. I wasn't using the correct RecordTypeId. 2. I needed to create a Contact that could reference the Business Account we had created. 3. After creating the ...
Zach Manning's user avatar
1 vote
Accepted

How to create a business account with the REST API

You're going to use the same endpoint. PersonAccounts are a weird Mashup of an entry in the Account table and an Entry in the Contact table. Linked by a foreign key Account.ContactId That said you'll ...
wellmstein's user avatar
  • 1,821
1 vote
Accepted

salesforce rest api invalid session id error when using access token

The solution was I defined my headers array as: $headers = array( "Authorization" => "OAuth " . $sf_access_data['access_token'] ); When i should have defined it as: $headers = array( "...
RealGigex's user avatar
  • 175
1 vote

Posting Jenkins build status to SFDC via rest API chatter

Check the section Post a comment with a binary file in Chatter REST API Developer Guide. To post a comment the syntax should look as below. curl -H "X-PrettyPrint: 1" -F 'json={ "body":{ "...
Saroj Bera's user avatar
  • 14.8k
1 vote

Convert cURL to Salesforce APEX rest api

A good place to start would be to look at the documentation on HttpRequest. Most everything should map fairly intuitively from cURL. For example... POST, GET, PUT, etc... are Http methods, so use ...
Derek F's user avatar
  • 63.2k

Only top scored, non community-wiki answers of a minimum length are eligible