Error while deserializing Azure ServiceBus Queue message sent from node.js (azure sdk)
azure-worker-roles, c#, deserialization, json, node.js
Solution
After some digging around, i found THIS article that helped me get a solution:
Client.OnMessage((receivedMessage) =>
{
var bodyJson = new StreamReader(receivedMessage.GetBody<Stream>(), Encoding.UTF8).ReadToEnd();
var myMessage = JsonConvert.DeserializeObject<MyMessage>(bodyJson);
});
If anyone has faced this issue and found a better solution, please let me know!
Thanks!
Problem
Here's my scenario: I'm sending an Azure ServiceBus Queue message from Node.js using the node azure sdk like so: ``` var message = { body: JSON.stringify({ foo: 'Bar' }) }; serviceBusService.sendQueueMessage('myQueue', message, function (error) { if (!error) { console.log('msessage sent'); } }); ``` I have a c# worker role that is listening to the Queue: ``` QueueClient Client = QueueClient.CreateFromConnectionString(connStr, QueueName); Client.OnMessage((receivedMessage) => { var body = receivedMessage.GetBody<string>(); }); ``` When the `GetBody` method gets executed, i get the following error: There was an error deserializing the object of type System.String. The input source is not correctly formatted