how to call sms gateway url from biztalk server - biztalk

I need to create a BizTalk solution wherein I'll need to call an SMS gateway URL from BizTalk server. Is there a way to do this?
The URL looks like below. I only need to pass the phone_number and the text_msg parameter in doing this.
http://111.111.1.111/sendsms.cgi?mobile_number=+6512345678&text_msg=test

If it is a REST API then you can use the WCF-WebHttp Adapter and pass the Phone Numbers and TExt message as variables in the URL itself.
These properties (Phone No and Text message) would need to be promoted and then will be passed dynamically.

This has been resolved by adding an Expression shape in my orchestration and in that expression I have placed this line of code.
sendPort_SendSms(Microsoft.XLANGs.BaseTypes.Address) = "http://111.111.1.111/api/sendsms.cgi?" + "mobile_number=" + varMobileNumber + "&" + "text_msg=" + varMessageBody;
I have declared my 2 parameters: mobile_number(varMobileNumber) and text_msg(varMessageBody) as variables so I can just pass whichever value in it.
This worked like a charm.

Related

Error in the JQL Query: XXX is a reserved JQL word

I'm trying to use Jira's REST API in order to get an issue key using its name (summary).
I do so using env variables and parameters that are received by the function (TestCaseID is the summary in this case).
My get requests receive following information:
var getUrl = {
url : "https://" +
process.env.JIRA_USERNAME +
":" +
process.env.JIRA_PASSWORD +
"#" +
process.env.JIRA_BASE_URL +
"/rest/api/2/search?jql=" +
`Summary~"\"${TestCaseID}\""` ,
method: "GET" };
But I get the following error:
Error in the JQL Query: 'Access' is a reserved JQL word. You must surround it in quotation marks to use it in a query.
this is because the TestCaseID contains this specific word (and unfortunately I can't change it).
I don't understand why it asks me to surround it in quotes since this is exactly what I did when adding the "\" and \"".
I tried multiple different approaches to fix it, but eventually, I receive the same error again and again.
Does anybody have an idea how I can solve it?
I managed to solve it in case someone will face same issue in the future:
I used postman in order to use the feature that provides the request for Nodejs as explained here: Convert postman api call to Node.js call
and saw that 2 backslashes are used instead of one. so adding a second one solved it for me :
`summary~"\\"${TestCaseID}\\""`

BizTalk WCF-WebHttp URI mapping problem with escaped variable

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&TECHNICIAN_KEY=MyKey&format=XML&INPUT_DATA=<?xml version=&apos;1.0&apos;?>
<API>
<name>email#host.com</name>
</API>"/>
</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&TECHNICIAN_KEY=MyKey&format=XML&INPUT_DATA=<?xml version=&apos;1.0&apos;?>
<API>
<name>{email}</name>
</API>"/>
</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&TECHNICIAN_KEY={key}&format=XML&INPUT_DATA=<?xml version=&apos;1.0&apos;?>
<API>
<value>email#host.com</value>
</API>"/>
</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.
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.

Adding elements in Biztalk Expression Editor

I have an orchestration that sends out emails and I'm trying to write out the email subject to include nodes from the XML. I want to write the following in the subject:
EDI 860 - PO Change Notification:(Buyer Name),(Buyer City),(Buyer State)
This is how I wrote it in the expression:
emailSubject = "EDI 860 - PO Change Notification:"+"/*[local-name()='Name' and namespace-uri()='']/*[local-name()='buyer_name' and namespace-uri()='']"+"/*[local-name()='Name' and namespace-uri()='']/*[local-name()='city' and namespace-uri()='']"+"/*[local-name()='Name' and namespace-uri()='']/*[local-name()='state' and namespace-uri()='']";
Is this correct? I'm pretty new to orchestrations and writing expressions. I didn't get any errors while writing and it seems like valid language, but I don't have a test environment to try it out on. I'm worried that the email will currently come out like this:
EDI 860 - PO Change Notification:(Buyer Name)+(Buyer City)+(Buyer State)
For starters. Get a test environment or at the very least test it in your dev environment. You should not release anything that has not been tested.
No, it would not work like that, see Using XPaths in Message Assignment
It would have to look like the below where you also tell it that it is an xpath and have the name of the message (msg)
myString = xpath(msg, "string(/*/book[1]/title)");
Even if it had worked it would look like the second one example, as you aren't adding the commas in the string concatenation.
Also rather than trying to use XPaths, you might want to look at using distinguished fields in your schema. This will make it a lot easier to refer to elements in your payload and make it easier for developers to read (it still uses XPaths under the hood).
To use the distinguished field you just refer to the message name & field name
e.g.
emailSubject = "EDI 860 - PO Change Notification:"+ msg.Name.buyer_name + "," + msg.Name.city + "," + msg.Name.state;

Setting the output file name in a biztalk send port

Good afternoon,
I'm trying to set the output file name in a send port and the available file name macros won't quite work.
I need something of the form "file.YYYYMMDD_HHMMSS". There's a datetime combined macro (with the wrong format), a time only macro, but no date only macro.
I don't have an orchestration for this process.
Is there any way I can set the file name from within a map or a pipeline?
Thanks!
You can achieve filename in this format YYYYMMDD_HHMMSS using following.
Use expression shape in orchestration and create four variables.
varDateTime=System.DateTime.Now; //varDateTime is datetime type
strDate=varDateTime.ToString("yyyyMMdd"); //strDate is string type
strTime=varDateTime.ToString("HHmmss"); //strTime is string type
outboundfilename= ""+strDate + " _ " +strTime +" "; //outboundfilename is the string variable.
Use the following code in Message Assignment Shape
msgOutbound(FILE.ReceivedFileName)=outboundfilename+".xml";
//File extension can be any based on your requirement. I have xml file type.
You don't need custom pipeline to do this.
You can do it with a custom pipeline or an orchestration but not with a map. Info on building a custom pipeline can be found here:
BizTalk MSDN Blogs
This can be set by setting the FILE.ReceivedFileName (instead of BTS.ReceiveFileName).
You can create a custom pipeline component to be placed on the send side (say encode stage), and then set the BTS.ReceiveFileName property to the custom file name value that needs to be set.
After this is done, you can use the %SourceFileName% macro in the Send Port. You can also refer to this MSDN forum link for more details

How do we send data via GET method?

I am creating a HTTPS connection and setting the request property as GET:
_httpsConnection = (HttpsConnection) Connector.open(URL, Connector.READ_WRITE);
_httpsConnection.setRequestMethod(HttpsConnection.GET);
But how do I send the GET parameters?
Do I set the request property like this:
_httpsConnection.setRequestProperty("method", "session.getToken");
_httpsConnection.setRequestProperty("developerKey", "value");
_httpsConnection.setRequestProperty("clientID", "value");
or do I have to write to the output stream of the connection?
or do I need to send the Parameter/Values by appending it to the url?
Calling Connection.setRequestProperty() will set the request header, which probably isn't what you want to do in this case (if you ask me I think calling it setRequestHeader would have been a better choice). Some proxies may strip off or rewrite the name of non-standard headers, so you're better off sticking to the convention of passing data in the GET URL via URL parameters.
The best way to do this on a BlackBerry is to use the URLEncodedPostData class to properly encode your URL parameters:
URLEncodedPostData data = new URLEncodedPostData("UTF-8", false);
data.append("method", "session.getToken");
data.append("developerKey", "value");
data.append("clientID", "value");
url = url + "?" + data.toString();
HTTP GET send data parameters as key/value pairs encoded within URL, just like:
GET /example.html // without parameters
GET /example.html?Id= 1 // with one basic parameter
GET /example.html?Id=1&Name=John%20Doo // with two parameters, second encoded
Note follow rules for character separators:
? - split URL in two pieces: adddress to left and paremeters to right
& - must be used to separate on parameter from another
You must know your platform specific native string encode function. Javascript uses escape, C# uses HttpUtility.UrlEncode
Yep, headers and properties are pretty much all you can send in a GET. Also, you're limited to a certain number of characters, which is browser dependent - I seem to recall about 1024 or 2000, typically.

Resources