Apex Integration Flashcards
What is API?
- Application Programming Interface
- Gets a request from the client, parses the request and tells the rest of the system what kind of operations to perform based on the result.
- (it is the messenger that takes request and tells the system what you want to do and returns the response back to you)
- They store resources, or individual record, using URI’s (Uniform Resource Identifiers)
What is Salesforce Connect?
allows us to establish a connection between our Salesforce org and an external database
Helpful because if we have a large amount of data in an outside system that we plan to continue using and don’t want to upload it to your org due to storage reasons or just for ease of use
How do we access URI’s?
We can access URIs at their corresponding Uniform Resource Locators (URLs), which are a part of the URI
What are the different HTTP Methods? Which are idempotent?
- GET
- PUT
- POST
- PATCH
- DELETE
Three of them are idempotent.
What is meant by idempotent? Which methods are idempotent?
- Being idempotent means that the end result of a set of duplicate requests with the same method to the same URL is independent of the number of duplicate requests
- We CAN get different status codes in responses from idempotent methods
Tldr: you can request a method X amount of times and it’s not going to make a difference to what the end result is going to be
GET PUT DELETE
What is GET?
- idempotent method
- Retrieves resource stored with the target URI
- Because we’re only reading data, not changing it, it makes no difference if we make a GET request once or 100 times
What is PUT?
- An idempotent method
- Either creates a resource at the target URL, or updates (read:overwrites) the entirety of the resource at said URL if it already exists (usually update)
- If you invoke a PUT API N times, the very first request will update the resource; the other N-1 requests will just overwrite the same resource state again and again – effectively not changing anything.
What is POST?
- NOT an idempotent method
- Lets us create a resource at the target URI or update an existing resource
- So POST is not idempotent because duplicate requests to the same URL will have compounding results
- The first POST operation will create one resource, the second will create a second resource, etc.
What is the difference between POST and PUT?
POST is used to “create new” resource.
PUT is used to “insert, replace if it already exists”. 5”.
What is PATCH?
- NOT an idempotent method
- Allows us to update parts of existing resource, but doesn’t overwrite the entire resource
- When making PATCH request, we only provide values for the fields that we want to change on the existing resource
What is DELETE?
- An idempotent method
- The first DELETE call will delete the resource with the specified URI
- Because the resource no longer exists after the first DELETE call, we can make as many duplicate DELETE requests as we want
- However, subsequent DELETE calls will give different status codes in their responses
What is HTTP Status Codes?
When we make a request using an HTTP method, the server will return a status code along with its response.
Status code represents the outcome of the operation.
Number Range: 100 - 599
Tell me about the 1xx range status codes
- Informational response:
- Indicates request was received, continue process
- 100: Continue
- No errors processing the request so far
Tell me about the 2xx range status codes
- Sucess: request was successfully received, understood, and acceped
- Common:
- 200 - Code Message: Ok
- Request was successful
-
201- Created
- resource was created
-
204 - No Content
- Request was successful but the body of response is empty (common response from DELETE call).
Tell me about the 3xx range status codes
- Redirects - further action required
-
300: Multiple Choice
- Multiple responses need to choose one
-
301: Moved Permanently
- Resource URL has changed and new URL resource is included in the response body
-
307: Temporary Redirect
- Resource URL has changed temporarily, make request to the URI included in body