FACEOFFERS Integration with SalesForce using Microsoft Azure Logic Apps and API Apps Part 2

FACEOFFERS_blog banner image_800_by_140_SalesForce

In Part 2, you are going to create 2 HTTP Action POST cards as shown below. This will allow you to POST the data from the Salesforce connector using the FACEOFFERS API. In order to create a Consumer, you have to make 2 API calls. In the first HTTP post, you are posting the GENDER, ADDRESS1, ADDRESS 2, CITY, STATE and ZIPCODE using the Consumers API call as shown here https://api.faceoffers.com/api/Consumers. This will create the Consumer and return a ConsumerId. You will then use the ConsumerId and POST the ConsumerId, MerchantId, MerchantLocationId, First Name, LastName, Email and PhoneNumber to create the MerchantConsumer using the MerchantConsumer API call as shown here https://api.faceoffers.com/api/MerchantConsumers. To get the MerchantId and MerchantLocationId, you will need to make a couple of API calls.

To get the MerchantId, use this API call. https://api.faceoffers.com/api/Merchants/ByUserId/{id}

To get the MerchantLocationId, use this API call. https://api.faceoffers.com/api/MerchantLocations/{merchantId}

For more information, here is a knowledgebase article on how to create a Consumer. https://faceoffers.jitbit.com/helpdesk/KB/View/2222576-how-do-i-create-a-consumer

FACEOFFERS_SalesFoce_LogicApp_2cards_Phase2

 

 

 

 

 

 

 

 

Step 1) In this step, you are going to configure an HTTP POST Action. Click on the HTTP card on the right-hand side of the page. This will add the card to the Logic App. To configure the card, use the following settings.

Repeat

@body(‘salesforceconnector4’).result.records

ScreenShot2454

 

ScreenShot2455

 

 

 

 

 

 

 

 

 

 

URI

 

POST

https://api.faceoffers.com/api/Consumers

Headers

{“Accept-Language”:”en-us”,”charset”:”utf-8″,”Content-Type”:”application/json”,”X-API-TOKENAUTH”:”FACEOFFERSTOKEN“}

Authentication

Leave this blank. The Authentication is taken care of in the X-API-TOKENAUTH request in the Header.

Body

{“Gender”: “NULL”,”Address1″: “@{repeatItem().MailingStreet}”,”Address2″: “NULL”,”City”: “@{repeatItem().MailingCity}”,”State”:”@{repeatItem().MailingState}”,”ZipCode”: “@{repeatItem().MailingPostalCode}”,”Image”: “@{repeatItem().PhotoUrl}”}

Step 2) In this step, you are going to configure a 2nd HTTP POST Action. Click on the HTTP card on the right-hand side of the page. This will add the card to the Logic App. To configure the card, use the following settings.

Repeat

@range(0, length(body(‘salesforceconnector4’).result.records))

URI

POST

https://api.faceoffers.com/api/MerchantConsumers

Headers

{“Accept-Language”:”en-us”,”charset”:”utf-8″,”Content-Type”:”application/json”,”X-API-TOKENAUTH”:”FACEOFFERSTOKEN“}

Authentication

Leave this blank. The Authentication is taken care of in the X-API-TOKENAUTH request in the Header.

Body
{“ConsumerId”: “@{actions(‘http’).outputs.repeatItems[repeatItem()].outputs.body.Id}”,”MerchantId”: “YOURMERCHANTID”,”MerchantLocationID”: “YOURMERCHANTLOCATIONID”,”FirstName”: “@{body(‘salesforceconnector4’).result.records[repeatItem()].FirstName}”,”LastName”: “@{body(‘salesforceconnector4’).result.records[repeatItem()].LastName}”,”Email”: “@{body(‘salesforceconnector4’).result.records[repeatItem()].Email}”,”PhoneNumber”: “@{body(‘salesforceconnector4’).result.records[repeatItem()].MobilePhone}”,”FullName”: “@{body(‘salesforceconnector4’).result.records[repeatItem()].LastName},@{body(‘salesforceconnector4’).result.records[repeatItem()].FirstName}”}

NOTE: salesforceconnecter4 is the name of the Salesforce Connector created in the previous post

If you have configured all the cards correctly, you should now be able to run the Logic App. To test, edit one of Contacts in Salesforce. This will reset the LastModifiedDate for the Contact. Next, click on Run Now. If the Logic App executes correctly, you should see a green checkmark next to the job under All runs and a 3 under SUCCEEDED in the Logic app run window as shown below. You can then log into the FACEOFFERS portal and view your Contact by clicking on the Consumers menu item.

FACEOFFERS_Salesforce_LogicApp_Success

 

Leave a Reply

Your email address will not be published. Required fields are marked *