2016-11-19 29 views
0

我有一個將信息發送到我的天藍色服務總線的小型python應用程序。我注意到每條消息都有「broker_properties」字典,並且有一個名爲「Label」的屬性,我可以從服務總線稍後訪問它。嘗試發送具有代理屬性的天藍色服務總線消息時出現400錯誤

我想送我的消息填充該屬性:

properties = {"Label":label} 
msg = Message(bytes(messagebody, "utf-8"), bus_service, broker_properties=properties) 
bus_service.send_queue_message("queue", msg) 

但這似乎並沒有工作。當執行上述命令時,我從Azure返回錯誤:

The value '{'Label': 'testtest'}' of the HTTP header 'BrokerProperties' is invalid. 

這是Python Azure SDK中的錯誤還是我做錯了什麼?

+0

模樣。 .NET客戶端具有Label屬性的Nooooo問題。 –

回答

1

根據您的代碼,問題是由於使用Python dict對象作爲broker_properties的值而引起的,但broker_properties值應該是json字符串。請參閱GitHub上的Azure SDK for Python中的測試code

所以請修改你的代碼如下。

properties = '{"Label": "%s"}' % label 

或者

import json 
properties = json.dumps({"Label":label}) 
+1

對於關閉,問題也在Azure SDK for Python問題跟蹤器上打開,並按照Peter Pan的說法解決。 https://github.com/Azure/azure-sdk-for-python/issues/890 –

+0

@LaurentMazuel感謝您的反饋。 –

相關問題