03-10-2020 10:15 AM - edited 03-10-2020 10:16 AM
Hi Everyone,
Looking for some help with configuration of REST API call step in a CCX script.
I am using an array string variable here and inputting the variable values into one array variable instead of creating 8 different variables for every field in a Make REST call step. Excellent recommendation from @Anthony Holloway
1) CRM does authentication by requiring username and password sent in Request Body. Since these values are going to be static, I was able to get them mapped and added into the string array variable used on the first Make REST Call.
2) Next another Make REST Call is required to be sent to search for a record based on either a Member # or SSN entered by a caller. These numbers are going to be dynamic each time for a call and they need to be sent in Request Body. I am unable to figure out how to send dynamic variable values in the Body of a REST Call.
Solved! Go to Solution.
03-12-2020 07:47 AM
The value for your set step should look something like this:
u"{\"ssn\":" + SSN + u",\"class\":\"Individual\", \"entity\":\"Business\"}"
This is assuming your SSN is held in a variable named SSN.
03-10-2020 01:20 PM - edited 03-10-2020 01:25 PM
I would recommend that you construct the body outside of the Make REST Call step, using like a Set step for example.
E.g.,
Steps
Set REST[4] = "<ssn>" + ssn + "</ssn>" Make REST Call (using REST[4] in Body field)
Alternatively, you can setup your body as a template string and use String.replace to add the SSN
E.g.,
Variables
body_template = "<ssn>%SSN%</ssn>"
Steps Set REST[4] = body_template.replace("%SSN%", ssn) Make REST Call (using REST[4] in Body field)
It is possible to perform the replacement in the Make REST Call step too, which saves you the one Set step, you just don't use the REST[4] like previously.
E.g.,
body_template.replace("%SSN%", ssn)
Or if you like to use the REST[4] for debugging or whatever reason, you can do this in the Body field too:
E.g.,
{ return REST[4] = body_template.replace("%SSN%", ssn); }
03-11-2020 08:30 PM
Hi Anthony,
Thanks for your response. Being new to programming, this is my first attempt at any programming, please pardon my ignorance.
Since, I need to send two other static name:value pairs along with this dynamic ssn value, I was trying to figure out how to include that in the set step. And, with my limited understanding, I thought the data is getting sent in xml format while we need to send in json format starting with the curly brace. I tried with few attempts in creating a set step for sending json data. The editor took following but I am not sure if it is correct. Could you please confirm? Once I get this correct, I plan to test with debugging of the script initially and then later using a RESTClient on Firefox with CRM application.
03-12-2020 07:47 AM
The value for your set step should look something like this:
u"{\"ssn\":" + SSN + u",\"class\":\"Individual\", \"entity\":\"Business\"}"
This is assuming your SSN is held in a variable named SSN.
03-12-2020 09:43 PM
Thank you, Anthony. That variable worked. Tried to read up on the JSON syntax, I couldn't find any explanation on the use of u character at the beginning, looks to be CCX specific. Could you please explain a little on that?
03-12-2020 10:29 PM
03-13-2020 12:04 PM
Thank you, Anthony. Much appreciated.
03-13-2020 12:44 PM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide