1

I am trying to use BizTak WCF-WebHttp adapter to send to Service Desk Plus CMDB API using Variable Mapping.

When trying using the browser, it works fine. Service Desk Plus CMDB API requires an URI like (strictly shortened for readability):

http://host.com/api/cmdb/ci?OPERATION_NAME=read&TECHNICIAN_KEY=Mykey&format=XML&INPUT_DATA=<?xml version='1.0'?>
<API>
    <name>email@host.com</name>
</API>

I have used the URI http://host.com/api/cmdb/ci and URL Mapping.

<BtsHttpUrlMapping>
    <Operation Url="?OPERATION_NAME=read&amp;TECHNICIAN_KEY=MyKey&amp;format=XML&amp;INPUT_DATA=&lt;?xml version=&apos;1.0&apos;?&gt;
        &lt;API&gt;
            &lt;name&gt;email@host.com&lt;/name&gt;
        &lt;/API&gt;"/>  
</BtsHttpUrlMapping>

This works fine, but I need a more dynamic approach. I tried using Variable Mapping, so I replaced the hard coded email address with a variable.

<BtsHttpUrlMapping>
    <Operation Url="?OPERATION_NAME=read&amp;TECHNICIAN_KEY=MyKey&amp;format=XML&amp;INPUT_DATA=&lt;?xml version=&apos;1.0&apos;?&gt;
        &lt;API&gt;
            &lt;name&gt;{email}&lt;/name&gt;
        &lt;/API&gt;"/>  
</BtsHttpUrlMapping>

Trying to save the URL Mapping with the variable I get an error.

WCF-WebHttp Transport Properties

Error saving properties. (System.InvalidOperationException) The UriTemplate

?OPERATION_NAME=read&TECHNICIAN_KEY=MyKey&format=XML&INPUT_DATA=<?xml version='1.0'?><API><name>{email}</name></API>

is not valid; each portion of the query string must be of the form 'name=value', when value cannot be a compound segment. See the documentation for UriTemplate for more details.

If I try a variable that is not within the escaped XML string, like with the key, then it works fine.

<BtsHttpUrlMapping>
    <Operation Url="?OPERATION_NAME=read&amp;TECHNICIAN_KEY={key}&amp;format=XML&amp;INPUT_DATA=&lt;?xml version=&apos;1.0&apos;?&gt;
        &lt;API&gt;
            &lt;value&gt;email@host.com&lt;/value&gt;
        &lt;/API&gt;"/>  
</BtsHttpUrlMapping>

My intention is to be able to use a variable within the escaped XML string. If that is not possible; I will have to turn to a dynamic adapter and Create the URI and URL mapping in an orchestration.

larjon
  • 21
  • 1
  • 4

1 Answers1

0

Did u understand why it said each portion of the query string must be of the form 'name=value? There are just a few ways to make UriTemplates work.

See how a UriTemplate works here. Here is an example that is valid:

  • weather/{state}/{city}?forecast={day}

So in your case you should make everything after INPUT_DATA= a variable. Which means the whole escaped XML string you were talking about.

r3verse
  • 1,000
  • 8
  • 19
  • Thanks for the explanation. Now I know how to make it work. However, in my case it was simplier to use an orchestration with a dynamic send port since the XML structure was quite large and complex, with a lot of dynamic data. – larjon May 20 '19 at 06:45
  • Makes sense @larjon. Don't forget to accept answers so questions don't stay open forever. – r3verse May 20 '19 at 08:03