IPaaS JavaScript Not Working

Please see below.  I have a use case where I need to connect to a system (KickServ) that only uses XML, so I need to write JavaScript to connect to the endpoint and process the XML data.  However, as seen below, I have a JavaScript that only uses standard JavaScript. I get a warning that the Async functions are not available in the current version supported by IPaaS.  Is there a way to get around this?  In addition, the script does not recognize the BTOA function, a standard JavaScript function.

https://app.screencast.com/nncN9KkKrc8x2

Any pointers would be appreciated.

Tevis

Asked by Tevis Boulware on Thu 6/27/24 7:35 PM
Hi David, see below. The KB article(s) doesn't really show/specify how to set the header correctly. Also, the configuration UI and documentation mentions that XML can be returned and parsed, but there is no option in the Connector UI to select XML, so I am assuming that we just need to return plain text.

https://app.screencast.com/87ydTnK50qhs9

Any ideas?

Thanks, Tevis
- Tevis Boulware Mon 7/1/24 12:27 PM
Sign In to leave feedback or contribute an answer

Answers (3)

This answer has been marked as the accepted answer
David Tod Fri 6/28/24 1:43 PM

Is your token value persistent? If so, then you can set it up as part of the credentials using the "API with Authorization Header" type authentication method.

My problem was that the token was temporary and dynamic with the application I was working with, and the authorization header was mildly non-standard. Yours looks more standard, and there should be a cookbook for this that matches. Look at Step 2 on this article  https://solutions.teamdynamix.com/TDClient/1965/Portal/KB/ArticleDet?ID=142165& for example.

My login (authentication) method was sending a username and password to get the authorization back in a JSON object, which I extracted and passed to my custom connector where the action (see earlier screenshot) included it as a header as part of the action definition.

It all seems a bit bonkers to me, but I've not found a good description of how these pieces fit together, and support was only mildly helpful. When I look at the article above, I can't help thinking that I probably screwed up and didn't solve the problem the right way.

p.s. I'm not with TDX. I'm just someone who had a similar problem and struggled mightily. I've posted this question in the Slack, but no-one has bitten on it yet!

No feedback
Hi David, the "API with Authorization Header" is not an allowed authentication method for the HTTP connector. See below to demonstrate what happens when I try to set this method.

https://app.screencast.com/DN4eV7nAHLTOv

Tevis
- Tevis Boulware Fri 6/28/24 1:55 PM
I'll see if I can't record something, but I ran into the same issue with using an "authorization" header as I recall. - David Tod Fri 6/28/24 1:59 PM
I think it all depends on whether your authentication and authorization method maps to an existing one. It doesn't help that some of the variables are named "AuthTemplate" and I'm like, which one?! I haven't found an article about authentication methods. - David Tod Fri 6/28/24 2:00 PM
Hi David. See below. I have set up the custom connector and can pull the XML data. But I have a weird situation where I can't extract the desired field in the returned XML response, but if I pass that response into a subflow I can.

https://app.screencast.com/QTPrUpdv8zzkO

Can you point me in the right direction?

Thanks, Tevis
- Tevis Boulware Mon 7/1/24 7:16 PM
Tevis, I've shared my zoom/booking info in Slack if you want to connect. One thought is when you get the xml response back, are you saving that as the data model for the response? Alternatively, you may need to build the data model as part of the connector. - David Tod Mon 7/1/24 7:34 PM
Hi David, See below. It appears to me, and by the help text, that I should be able to set the response data type to XML. Also, can you point me in the right direction on setting up the data model for the connector?

When I pass the response to the subflow, and I copy and paste the response to the data model of the subflow, the subflow recognizes it as XML.

I am getting closer. There are only a few more hurdles to cross before I have everything I need to fully develop the use case.

Tevis
- Tevis Boulware Tue 7/2/24 6:47 PM
Below?

My recollection of the data model process is that if you have a relatively complex structure, you have to start at the bottom of the tree and build the elements of the lowest parent, then add that object to it's parent, etc., e.g.

someObject
- child prop
- child object
-- child object prop
-- child object prop

You'd built "child object" first adding the child object properties, then build "someObject" and add "child obj" and "child object" to it.
- David Tod Wed 7/3/24 9:47 AM

David Tod Fri 6/28/24 11:06 AM

Now you're getting into areas that make my head hurt! You may have to experiment a bit and see what headers get sent and received. I had to create a custom connector relatively recently where the Authorization header used 

'Authorization': 'BamAuthToken ....etc'

which I did by adding a header to methods (see image), but that might be my not understanding Authentication methods. Looking at other connectors, I'm a bit mystified to be honest. I'm not sure how other connectors do it, but they must. The more I look at Authentication methods, the less sense they make, since it's not clear how you get from an Authentication method to an Authorization header.

1 of 1 users found this helpful.

David Tod Fri 6/28/24 8:58 AM

Can't you just use a generic HTTP connector?

No feedback
I didn't do my research well enough and didn't realize IPaaS had an HTTP connector--DOH.

The Kickserv endpoint requires a token be passed with every call, and this is the header I use in my script:

headers: {
'Accept': 'application/xml',
'Content-Type': 'application/xml',
'Authorization': `Basic ${encodedToken}`

}
Which of the available authentication methods do you suggest?

Thanks, Tevis
- Tevis Boulware Fri 6/28/24 10:51 AM
Hi David, see below and I have tried the different auth methods but nothing seems to work:

https://app.screencast.com/wy1hEF2ELkQ5V

I suspect I am missing something, but I can't quite put my finger on it.

Tevis
- Tevis Boulware Fri 6/28/24 12:46 PM
David, I would like to add how important this effort is. It is a proof of concept that shows whether existing Drupal/PHP scripts can be ported into TeamDynamix/IPaaS. If successful, we have a line of other Drupal/PHP applications that want to move.

If necessary, I would like to meet with anyone on the TDX side who can help me with the low-level details, such as how to make a custom connector and add methods and parameter strings. If this effort fails, TeamDynamix will lose quite a bit of support from our automation team.

I don't have any problems with the "logic" or algorithms, but the low-level details are holding me back.

Thanks, Tevis
- Tevis Boulware Fri 6/28/24 1:11 PM
Hi Tevis, is the token static? If so, you should be able to make credentials using the API Key with Authorization Header method and set the API Key to Basic {basic64Token}. If you have a connector, make sure the Allowed Authentication Method Types includes Generic API Key and then set the Authentication Method to API Key with Authorization Header.

If it's not static and you need to refresh tokens, it's still possible but I'd have to research some more.
- Steven Applegarth Fri 6/28/24 5:14 PM
Side note, if you don't have a connector made, I would definitely recommend making yourself a kickserv rest connector if you don't have one currently. https://solutions.teamdynamix.com/TDClient/1965/Portal/KB/ArticleDet?ID=142018 - Steven Applegarth Fri 6/28/24 5:29 PM