About EasyMorph Tutorials & Examples Web-help

WebRequest and parameters

Trying to use the Web request to get access to a REST api. I have it working when I paste the json string as a text. Although I have some variables that come from the columns that I’ve loaded from SQL table. Two questions. Is there a way to somehow save the column (1 row) into a parameter then use that parameter in the Body as Text? I tried but not sure if its not allowed.

Second question is if I can’t do it that way and instead i have to create my own json string, (i looked over your support topic) I need the JSON to be a specific tree. And can’t seem to figure out how to get it to work out.

Sample of json string:
{
“Messages”: [
{
“From”: {
“Email”: “testme@yahoo.com”,
“Name”: “Test”
},
“To”: [
{
“Email”: “testme2@yahoo.com”,
“Name”: “Test Me2”
}
],
“Subject”: “Hi!”,
“TextPart”: “Hello!”

    }
]

}

Thanks!
Flowy

Hello,

To call web service with REST api, I use module like :
image

image

You can use action “Construct JSON” several time to create this JSON.

1 Like

Yes, you can use the “Iterate web request” action. It allows specifying the request body from a column. Since the table has only 1 row, the action will perform exactly 1 request.

You can construct JSONs of any complexity using the “Construct JSON” action. See below an example that constructs the sample JSON that you provided:

construct-json.morph (4.4 KB)

Thanks Dmitry!!! I’ll give this a try today!

Hi Dmitry!

I couldn’t open the sample program since we have the older version of easymorph. But I figured it out from the picture you provided.

Worked great with the list creation and then calling the rest API directly!

Thanks
Flowy

Dmitry,

One more related question. Let’s say I have a list of To people. Unfortunately I can’t set it up to be an JSON array of multiple emails because I want to customize it to each user. I have a list that I’m pulling for SQL so lets say like 1-10 users (name, and emails). I want to create each row into a JSON string. I need to iterate the results table above but grabbing the json string row by row from the To List. Possible?

Thanks
Flowy

Not sure I understand your question precisely, but what I read should be possible to do using iterations.

To learn more about EasyMorph visit easymorph.com.