Thanks! I've got a lot of work to try to understand what you've provided, and how I can utilize this
with the RESTClient, RESTResponse, and RESTRequest components. Or should I go another
way? I'm trying to utilize the TrueDialog SMS API, and am assuming I need to use these
REST components. If so, could you please provide an insight on how I do so. I am an
experienced VCL Delphi programmer (since 1988) but an completely confused by
Web Services.
Thank you so much!
Jim Sawyer
Hi,
How can I dynamically put into REST params the
values shown in the following CURL snippet?
{
"Channels": [22],
"Targets": ["+19727689383"],
"Message": "Eureka! I found it!",
"Execute": true
}
This is a POST request.
You can you TJsonObject (System.JSON).
Try something like:
var
lJsChannels : TJsonArray;
ljsTargets : TJsonArray;
lJsObj : TJsonObject;
begin
lJsObj := TJsonObject.Create;
lJsChannels := TJsonArray.Create;
lJsChannels.AddElement( TJsonNumber.Create(22) );
lJsTargets := TJsonArray.Create;
lJsTargets.AddElement( '+19727689383' );
lJsObj.AddPair( 'Channels', lJsChannels );
lJsObj.AddPair( 'Targets', lJsTargets );
lJsObj.AddPair( 'Message', ''Eureka! I found it!' );
lJsObj.AddPair( 'Execute', TJsonTrue.Create );
lJsObj.ToString will display the jsonObject -> { "Channels": [22], "Targets": ["+19727689383"], "Message": "Eureka! I found it!", "Execute": true }
lJsObj := TJsonObject.ParseJSONValue( '{ "Channels": [22], "Targets": ["+19727689383"], "Message": "Eureka! I found it!", "Execute": true }' ) as TJsonObject;
and you're good to go
HTH,
Clément
Connect with Us