Week 1 Homework: Q #1: What are the components of an HTTP request? End point, Request Type, headers(automatically added by Salesforce) and Body/Payload (optional) Q #2: What are the components of an HTTP response? Header, statuscode and body/payload Q #3: What are the 2 most popular payload formats? JSON and XML Q #4: Explain JSON format in your own words. Give an example. Commonly used datatype used for transferring data. It is basically a map of key,value pairs { "Key1":"Value1", "Key2":"Value2", "Key3":{"KeyA":"ValueA"}, "Key4_objectArray":[ {"field1":"value1","field2":"value2"}, {"field1":"value1","field2":"value2"} ] } Q #5: We have this endpoint:https://735ef563-176d-431c-85ce-2cc07056ef03.mock.pstmn.io/payments/link Here's your task: Make an API request and verify that you are successfully receiving a response (status code 200) Parse the response and get the IP address of the transaction. Solution: HttpRequest request = new HttpRequest(); request.setEndpoint('https://735ef563-176d-431c-85ce-2cc07056ef03.mock.pstmn.io/payments/link'); request.setMethod('GET'); Http http = new Http(); HttpResponse response = http.send(request); String responseBody = response.getBody(); Map<String,Object> responseMap = (Map<String,Object>)JSON.deserializeUntyped(responseBody); Map<String,Object> transactions = (Map<String,Object>)responseMap.get('transaction'); Map<String,Object> details = (Map<String,Object>)transactions.get('details'); System.debug(details.get('IP'));