# Postman & Salesforce REST Web Services

Accessing an Apex web service from outside Salesforce

In this post we are going to talk about sending a request from a client that is outside Salesforce to an Apex web service in Salesforce. We are going to use the Postman client.

# Salesforce REST API Integration w/OAuth

There are number of reasons you may want to interact with your instance of Salesforce from outside Salesforce. You may have an app or service that you want to allow to access your Salesforce data. In our case, we have an external call center that needs to be able to access and manipulate our Salesforce data.

We need our external call center to be able to create new Leads, update Lead information and schedule appointments. There is a lot of information online about the Salesforce REST API and Connected Apps, but it is widely distributed and can be confusing. …

# Apex Trigger Test Coverage

Let’s untangle the subject of code coverage requirements for Apex Triggers on the Salesforce platform.

I recently inherited a Trigger that had been neglected for some time. The code was stringy, highly coupled and poorly tested. I added a few lines of code and tried to deploy it. It failed. The error:

`0% code coverage. Each trigger must have at least 1% code coverage.`

I ran the test in our production environment and in two sandboxes. It had 31 percent code coverage. …

# Base 10 to Base 2

Computers only know binary. Base 2 is binary. Let’s convert a couple of integers to their binary representation.

The number 10.

n = 10

n/2 = 5 with a remainder of 0, so the number in our binary string is 0.

`0`

Now n=5

n/2 is 2 with a remainder of 1.

So our number is 1.

`10`

Now n = 2

n/2 = 1 with a remainder of 0

So our number is 0.

`010`

And that leaves us with 1, which is our first number

`1010`

Another representation of what we…

# AND, OR, XOR — Bitwise Operators

Let’s take a minute to breakdown bitwise operators. Bitwise operators are operators that operate on `ints` and `uints` at the binary level.

< 5 Seconds on Binary

0 represents closed or off or false.

1 represents open or on or true.

The binary operators take two inputs, or arguments, and returns one output. The inputs can only be 0 or 1.

AND

When we use the AND operator, we are effectively saying, if the first argument the second argument are true, then the result is true, or 1. Otherwise the result is false, or 0.

`0…`

# Apex & AES256 Bit Encryption

is an encryption algorithm, or cipher, that is the current industry standard used to encrypt/decrypt files and data transmitted over secure file transfer protocols like HTTPS, FTPS, SFTP etc.

While complicated on a number of levels, in the era of high-level programming languages and frameworks, encryption is not difficult to implement. …

# Visualforce Date Field without sObjects

Salesforce, like the Internet, was built on the fly and in retrospect we probably should have done things differently. While Apex and Visualforce provide a lot of functionality and convenience, some things should just be easier. Enter `<apex:inputField />` and `<apex:inputText />` and `<apex:input />`.

Scenario 1: Capture text data and bind it to a sObject

No problem. We can use `<apex:inputField />`:

`<apex:inputField value="{! Account.FirstName }"                  html-placeholder="First Name" />`

Scenario 2: Capture date and bind it to a sObject

No problem. We can use the same component and just add `type="date"`:

`<apex:inputField value="{! Account.PersonBirthDate }"                 html-placeholder="Birth Date"                 type="date" />`

# The Anatomy of a SOAP Message

Most of us interact with REST APIs on a regular basis, but from time-to-time we need to interact with SOAP APIs as well. For those of us with less exposure to SOAP, REST APIs are like the Shire and SOAP APIs are a little like Mordor. They are dark and scary and full or orcs.

A SOAP message is not as bad as it looks. …

# Apex Triggers for Custom Validations

Salesforce has built-in validations that can be applied to specific fields, but these validations are somewhat rigid and limited. When searching for programatic solutions there seemed to be confusion and hesitancy regarding using triggers and custom validations. Once I figured out the solution, however, I found that they are relatively easy to build and limitless in versatility.

Two reasons to build custom validations are extensibility and searchability. We can add features and conditions to our validation at a later date. Additionally, everything is the codebase is easily searchable which makes debugging a less painful task.

# SOAP Requests with Postman

Postman is a clean, easy-to-use REST client, but it also works well for sending SOAP message via HTTP. Configuring Postman for a SOAP request is similar to a REST configuration.

For the purpose of this walkthrough we’ll use a mock company called Robot Lenders. We will send a SOAP request, or message, containing applicant information for a loan pre-qualification.

VERB and URL

We’ll submit a POST request to the Robot Lenders API using the following URL and endpoint: of https://www.robot-lending.com/quick-loan

## Kris Sparks

Software developer. Turing School alum.

Get the Medium app