How to Set URL and Authorization Token in BizTalk Dynamic REST Post

Here are some samples that might be useful if you need to dynamically send a REST “POST” message.

Of course, in the real world, the token and the URL would probably be some type of configuration variable.

YourMsgRequestName(WCF.HttpHeaders) =
        "Accept: application/json" +
        "\r\n" + 
        "Content-Type: application/json " +
        "\r\n" + 
        "X-AUTH-TOKEN: yourSecretAuthTokenHere" ;

// Add additional parts to the base URL Address 
YourMsgRequestName(WCF.HttpMethodAndUrl) = 
   "<BtsHttpUrlMapping>" + 
   "   <Operation Name='Post' Method='POST' Url='/messages/email' />" + 
   "</BtsHttpUrlMapping>";

YourMsgRequestName(WCF.VariablePropertyMapping)=System.String.Empty;
YourMsgRequestName(WCF.SuppressMessageBodyForHttpVerbs)="GET";

YourMsgRequestName(BTS.RetryCount) = 0;
YourMsgRequestName(WCF.MaxReceivedMessageSize)=2147483647;
YourMsgRequestName(WCF.OpenTimeout)  = "00:01:00";
YourMsgRequestName(WCF.CloseTimeout) = "00:01:00";
YourMsgRequestName(WCF.SendTimeout)  = "00:01:00";

// how to override Dynamic Pipeline Configuration Values: 

// This sets the root name and namespace in the Receive Pipeline (in the two way SendPort) 
// (https://jeremyronk.wordpress.com/2011/08/01/configure-pipeline-dynamically/) 
// Instead of doing this, we can put these values in our custom pipeline directly. 
VarRootName = "SendEmailResp"; 
VarNamespace = "http://YourProject.Schema.Response";
SendMailReq(BTS.SendPipelineResponseConfig) = 
  "<Root xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'><Stages><Stage CategoryId='9d0e4103-4cce-4536-83fa-4a5040674ad6'><Components><Component Name='Microsoft.BizTalk.Component.JsonDecoder'><Properties><RootNode vt='8'>" + 
   VarRootName + 
   "</RootNode><RootNodeNamespace vt='8'>" +
   VarNamespace + 
   "</RootNodeNamespace></Properties></Component></Components></Stage></Stages></Root>";

DynPortName(Microsoft.XLANGs.BaseTypes.Address) = "https://your.api.com"; 
DynPortName(Microsoft.XLANGs.BaseTypes.TransportType) = "WCF-WebHttp"; 

Leave a Reply