new REST ftr. in latest 2467 build Explained.

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
Jaymer
Posts: 2448
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

new REST ftr. in latest 2467 build Explained.

Post by Jaymer »

Thanks to Vlad (and team) for rapidly getting this mod into the latest build.
Screen Shot 2018-07-26 at 11.32.08 PM.png
Screen Shot 2018-07-26 at 11.32.08 PM.png (33.76 KiB) Viewed 15286 times
The Base URL can now be a variable - this is easily seen in the Changelog.
But why is that needed?

Recently in 2466, Vlad already enhanced the Base URL (a feature pushed by a few of us) because it used to force a ? in between the URL and a parameter.
Using a simple REST service that allowed URL encoding, this sufficed. If you needed to build a simple string like:
xxx.url/api/v1?custid=1&invoice=1001
then aware did that from the start. But, some services needed this:
xxx.url/api/v1/lists/1001/members

In this case, if you put lists/1001/members in a parameter variable, then aware would send this:
xxx.url/api/v1?lists/1001/members
which would be invalid.

So, the 2466 fix allowed you to start your parameter with a "/" and then aware would NOT insert the ? resulting in this:
Base URL = xxx.url/api/v1
parameter = /lists/1001/members
Aware sends: xxx.url/api/v1/lists/1001/members

This would work perfectly for a GET and data would be returned just fine.

BUT WHAT ABOUT A POST?
Using my example, MailChimp, you use the exact same URL for a GET and a POST.
But the POST needs to send the data in a JSON string.

This caused a problem because now you need 2 variables...
one for the BASE URL, because the LIST ID that you want to add a member to is part of the URL,
and the 2nd parm is the JSON string.
WHY? You need your REST service to be dynamic. So you have to calc. your BaseURL to insert the appropriate CustID, or Invoice#, etc. We can now build this in Process before REQUESTing the service.

Code: Select all

LoggedInRegularUser.TempRESTBaseURL = 'https://us18.api.mailchimp.com/3.0/lists/' + MC_lists.listid + '/members'
Using 2466, and the new feature worked fine for a GET but not the POST.
Thankfully, the latest build 2467 essentially allows for 2 variables... 1 in the URL, 1 as the Parm string. (see above image).

This worked perfect on my 1st attempt posting members into a list in MailChimp.

--> JaymerTip
Last edited by Jaymer on Mon Oct 07, 2019 4:52 am, edited 1 time in total.
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
Rennur
Posts: 1191
Joined: Thu Mar 01, 2012 5:13 am
Location: Sydney, Australia

Re: new REST ftr. in latest 2467 build Explained.

Post by Rennur »

Truly appreciate this helpful explanation, thanks Jaymer. Great stuff!
ACDC
Posts: 1142
Joined: Sat Jun 30, 2007 5:03 pm
Location: California, USA

Re: new REST ftr. in latest 2467 build Explained.

Post by ACDC »

Thanks for this input Jaymer, this is a valuable explanation like many other of your posts on this forum :D
Post Reply