According to MSDN a Brokered Message can be submitted via the REST API and this brokered message can have the Properties key value pair as part of the message. I have been able to submit a Brokered message but when I recieve it the Properties field on the message is not populated. I must be encoding the Properties JSON incorrectly.
Here is the code snippet
WebClient webClient = new WebClient();
webClient.Headers[HttpRequestHeader.Authorization] = _token;
webClient.Headers["Content-Type"] = "application/atom+xml;type=entry;charset=utf-8";
Guid messageId = Guid.NewGuid();
webClient.Headers["BrokerProperties"] = @"{""MessageId"": ""{" + messageId.ToString("N") + @"}"", ""TimeToLive"" : 900, ""Properties"": [{""Key"" : ""ProjectId"", ""Value"" : """ + message.ProjectId + @"""}]}";
// Serialize the message
MemoryStream ms = new MemoryStream();
DataContractSerializer ser = new DataContractSerializer(typeof(RespondentCommitMessage));
ser.WriteObject(ms, message);
byte[] array = ms.ToArray();
ms.Close();
byte[] response = webClient.UploadData(fullAddress, "POST", array);
string responseStr = Encoding.UTF8.GetString(response);
Does anyone have an example of submitting a BrokeredMessage using the BrokerProperties HTTP Header?
It looks like the servicebus team has put up some silverlight and windows phone service bus samples on codeplex at http://servicebus.codeplex.com/. I quickly looked at the code for the silverlight chat sample and it appears to have all I need to publish brokered messages via the RESTFull API.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With