Overview

This method is used to send messages to subscribers in a Group, Division or Organization. The message will be sent to all active subscribers in the specified Group, Division or Organization.

Notes:

A user (APIKey account) can make up to 10 parallel requests or use multiple threads concurrently.

For sending messages, a limit of 100 messages per request is Recommended.

 

Syntax

C#

[OperationContractAttribute()]
SBT.API.DataContracts.MessageCenter.WSMessageResponse SendMessageToOrg(
   string securityToken,  
   string message,
   List<WSOrgRecipient> orgCode,
   string note,
   string statusUrl  
)

 

WSDL

 

Production: https://ui.solutionsbytext.com/Sbt.App.SetUp/WSServices/MessageWSService.svc?singlewsdl

Staging: https://test.solutionsbytext.com/Sbt.App.SetUp/WSServices/MessageWSService.svc?singlewsdl

 

Parameters

securityToken

– String[1000] (Required) – SecurityToken to authenticate the user.

message

– string[160] (Required) – Content of the message to be sent.

orgCode

* OrgCode – String[20] (Required) – Organization Code of the group, division or organization.
* List <CustomFields> (Optional) – Customfields contains collection of key – value pairs.

note

– String[500] (Optional) – This is a custom ID which is used to track the message transaction.

statusUrl

– String[200] (Optional) – Status URL that can be used to post message status information to a file.

 

Return Value

WSMessageResponse
NAME TYPE DESCRIPTION
Result bool True/False whether the call was successful or not.
ErrorCode int For Success/Failure it will generate an error number.
Message string Message related to the error code
TransactionTicket string ID created from message; this can be used in the ‘Get Message Status’ function to check the delivery status of the message.
Note string Note created from message; this can be used in the ‘Get MessageStatusByNote’ function to check the delivery status of the message.

 

Example

C#

MessageClient messageResult = new MessageClient("MessageWSServiceHttpEndpoint");
    string securityToken = txtToken.Text;
    string message = txtMessage.Text;

    //Create custom fields             
        List<CustomField> customFields = new List<CustomField>();
        CustomField customField = new CustomField();
        customField.Key = txtKey.Text;
        customField.Value = txtValue.Text;
        customFields.Add(customField);

    //Create recipients  
        List<WSOrgRecipient> orgCodes = new List<WSOrgRecipient>();
        WSOrgRecipient wSOrgRecipient = new WSOrgRecipient();
        wSOrgRecipient.OrgCode = txtOrgCode.Text;
        wSOrgRecipient.CustomFields = customFields.ToArray();
        orgCodes.Add(wSOrgRecipient);

        string note = txtNote.Text;
        string statusUrl = txtStatusURL.Text;

        WSMessageResponse wSMessageResponse = messageResult.SendMessageToOrg(securityToken, message, orgCodes.ToArray(), note, statusUrl);
        //process response  
            if (!wSMessageResponse.Result)
            {
                //handle error      
                lblError.Text = wSMessageResponse.Message;
            }
            else
            {
                //handle success      
                lblError.Text = wSMessageResponse.Message;
            }

SOAP

Soap Request 
              
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://SBTService/ServiceContracts/" xmlns:dat="http://SBTAPIService/DataContract/" xmlns:ser1="http://schemas.microsoft.com/2003/10/Serialization/">
   <soapenv:Header/>
   <soapenv:Body>
      <ser:SendMessageToOrg>
         <!--Required:-->
         <ser:securityToken>Security Token</ser:securityToken>
         <!--Required:-->
         <ser:message>Message content</ser:message>
         <!--Required:-->
         <ser:orgCode>
            <!--Zero or more repetitions:-->
            <dat:WSOrgRecipient>
               <!--Required:-->
               <dat:OrgCode>Organization code (Group, Division, Organization)</dat:OrgCode>
               <!--Optional:-->
               <dat:CustomFields>
                  <!--Zero or more repetitions:-->
                  <dat:CustomField>
                     <!--Optional:-->
                     <dat:Key>test key</dat:Key>
                     <!--Optional:-->
                     <dat:Value>test value</dat:Value>
                  </dat:CustomField>
               </dat:CustomFields>
            </dat:WSOrgRecipient>
         </ser:orgCode>
         <!--Optional:-->
         <ser:note>custom note</ser:note>
         <!--Optional:-->
         <ser:statusUrl>status URL</ser:statusUrl>
      </ser:SendMessageToOrg>
   </soapenv:Body>
</soapenv:Envelope>
  
Soap Response
 
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <SendMessageToOrgResponse xmlns="http://SBTService/ServiceContracts/">
         <SendMessageToOrgResult z:Id="i1" xmlns:a="http://SBTAPIService/DataContract/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
            <a:Result>true</a:Result>
            <a:ErrorCode>1281</a:ErrorCode>
            <a:Message>Message queued successfully</a:Message>
            <a:TransactionTicket>Transaction ticket</a:TransactionTicket>
            <a:note>Custom Note</a:note>
         </SendMessageToOrgResult>
      </SendMessageToOrgResponse>
   </s:Body>
</s:Envelope>

REST

Method: POST

URL: https://ui.solutionsbytext.com/SBT.App.SetUp/RSServices/MessageRSService.svc/SendMessageToOrg

Sample C# Code:

List<WSOrgRecipient> listOrgRecp = new List<WSOrgRecipient>();
                List<CustomField> lstCustomFields = new List<CustomField>();
                CustomField customField1 = new CustomField
                {
                    Key = "Key1",
                    Value = "Value1"
                };
                lstCustomFields.Add(customField1);
                CustomField customField2 = new CustomField
                {
                    Key = "Key2",
                    Value = "Value2"
                };
                lstCustomFields.Add(customField2);

                WSOrgRecipient orgRecipient = new WSOrgRecipient
                {
                    OrgCode = "OrgCode",
                    CustomFields = lstCustomFields};
                listOrgRecp.Add(orgRecipient);

                var requestdata = new
                {
                    securityToken = "validsecurityToken",
                    message = "Testing the message",                     
                    orgCode = listOrgRecp,
                    note = "sample note",
                    statusUrl = "sample statusUrl"
                };

                string data2 = JsonConvert.SerializeObject(requestdata).ToString();
                
                System.Net.WebClient webClient = new System.Net.WebClient();
                webClient.Headers["Content-type"] = "application/json";
                webClient.Encoding = Encoding.UTF8;
var strSendMsgToOrgResponse = webClient.UploadString("https://ui.solutionsbytext.com/SBT.App.SetUp/RSServices/MessageRSService.svc/SendMessageToOrg", "POST", data2);
Note:“strSendMsgToOrgResponse” contains the output response as return values 

 

Response:

The response will be in JSON format like below:

{" SendMessageToOrgResult": {
   "Result": true,
   "ErrorCode": 1281,
   "Message": " Message sent successfully",
   "TransactionTicket": "AA13J-0618V-15389-174L0",
   "Note": " Some Notes",
   }}

 

Send Feedback