Yassine.R | 2019-12-16 17:11:33 UTC | #1
Hello Team,
Need your help please to set up a REST API POST request to update or insert a record from PureCloud (Script/Architect) into Salesforce, by using Salesforce POST REST API method.
I am able to Get data from the Salesforce Object (Standard or Custom Field) via REST API GET requests.
What I now want to do : push customer data from PureCloud to SFDC :
- I duplicated an existing Data Action (REST API GET)
- I then changed the type of request to POST.
I don't know which configurations I should put in the JSON formula.
Could you please assist me with a simple code example to set up in PureCloud.
Example: Updating the caller's phone number
Thank you in advance for your help.
anon28066628 | 2019-12-16 17:43:02 UTC | #2
<a class="attachment" href="/forum/uploads/db6296/original/2X/3/346327fd5e4f2ffe82a6a1a9141466931e8e1bfe.json">Update-SF-object-configurable-field-with-configurable-value.json</a> (2.3 KB)
Here is a sample action for updating a customer field. Please see the documentation here for configuring the input and output contracts (JSON schemas), and the request and response configurations (Velocity templates, and JSONPath expressions).
https://help.mypurecloud.com/articles/create-custom-action-integrations/
These resources may also be helpful:
https://jsonschema.net/#/editor
http://jsonpath.com/
https://help.mypurecloud.com/articles/velocity-macros-data-actions/
https://help.mypurecloud.com/articles/response-configuration-data-actions/
Yassine.R | 2019-12-17 14:04:43 UTC | #3
Hi Smith,
Thank you for your help and your quick return.
From the elements you sent me, I tried to build the attached query.
My need is very simple : for a given contact X (Smith, DUPOND), I want to update his existing mobile phone.
In PureCloud, I have the following error code :
[spoiler]Execute: The requested resource was not found.
- REST call for action execute failed. Message:Request to backend service failed. Response from web service: [{"errorCode":"NOT_FOUND","message":"The requested resource does not exist"}] [249e2869-d938-4400-af95-a7d4cb184e81][/spoiler]
My apologies, I am growing in skill in PureCloud and not very familiar with the Json language.
This is the Query : { "name": "Push Customer Data To CRM - Exported 2019-12-17 @ 14:40", "integrationType": "salesforce-datadip", "actionType": "custom", "config": { "request": { "requestUrlTemplate": "/services/data/v38.0/sobjects/$salesforce.escReserved(${input.Firstname})/$salesforce.escReserved(${input.Lastname})", "requestType": "PATCH", "headers": { "UserAgent": "PureCloudIntegrations/1.0" }, "requestTemplate": "{\"MobilePhone\": \"${input.MobilePhone}\"}" }, "response": { "translationMap": {}, "translationMapDefaults": {}, "successTemplate": "${rawResult}" } }, "contract": { "input": { "inputSchema": { "title": "Contact", "type": "object", "required": [ "Firstname", "Lastname", "MobilePhone" ], "properties": { "Firstname": { "description": "The SF Object FirstName to update", "type": "string" }, "Lastname": { "description": "The SF Object LastName to update", "type": "string" }, "MobilePhone": { "description": "The value to update the Object field.", "type": "string" } }, "additionalProperties": true } }, "output": { "successSchema": { "type": "object", "properties": {}, "additionalProperties": true } } }, "secure": false }
anon28066628 | 2019-12-17 14:34:03 UTC | #4
Hi Yassine,
Can you post a non-data action sample of a query that does work? Perhaps a working query from Postman?
Jason_Mathison | 2019-12-18 14:51:17 UTC | #5
Also, please post an export of your data action instead of cutting and pasting chunks of configuration. The forum has a habit of hiding characters, making it hard to figure out what is going wrong.
Yassine.R | 2019-12-23 10:56:48 UTC | #6
Hi,
Thank you for your help. As a new user, I Cannot attach an export of my data action.
I fixed my issue. I followed the example sent by Smith_Rj and all works fine.
Do you an example of query to create data on CRM, from pureCloud, for new contacts which does not exist ?
Thanks a lot for your help.
Regards,
system | 2020-01-23 10:56:49 UTC | #7
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 6743