私はAzure iotを初めて使用しています。私は残りのAPIを使用して紺碧のiotハブに共有アクセスポリシーを作成しようとしています。Rest APIを使用したAzure IoT Hubでの共有アクセスポリシーの作成
https://management.azure.com/subscriptions/{subscription-Id}/resourceGroups/{group-name}/providers/Microsoft.Devices/IotHubs/{hub-name}?api-version=2016-02-03");
と私のJavaコードは
String policyold = "{\"tags\" : {}, \"location\": \"East Asia\",\"properties\" : \"authorizationPolicies\" : [{\"name\" : \"policy-namw\", \"primaryKey\" : \"{mykey}\" ,\"secondaryKey\" : \"secondary-key\" ,\"permissions\" :[\"ServiceConnect\" ,\"RegistryRead\" ,\"RegistryWrite\" ,\"DeviceConnect\"]}],\"eventHubEndpoints\" : { \"events\" : {\"messageRetentionInDays\":\"2\"}}}";
StringEntity input1 = new StringEntity(policyold);
input1.setContentType("application/json");
input1.setContentEncoding("UTF8");
put.setEntity(input1);
put.setHeader("Authorization", token);
HttpResponse r2 = httpclient2.execute(put);
System.out.println(r2.getStatusLine());
String content2 = EntityUtils.toString(r2.getEntity());
org.json.JSONObject recvObj2 = new org.json.JSONObject(content2);
ですが、私はfollowiingエラーに直面しています。
HTTP/1.1 400 Bad Request {"error":{"code":"InvalidRequestContent","message":"The request content was invalid and could not be deserialized: 'Error converting value \"authorizationPolicies\" to type 'System.Collections.Generic.Dictionary`2[System.String,Newtonsoft.Json.Linq.JToken]'. Path 'properties', line 1, position 76.'."}}
また、このチュートリアルを使用しています。 https://msdn.microsoft.com/en-us/library/mt589015.aspx
これを解決するのに役立つ人はいますか?
Azure IoTハブJava SDKを見れば、簡単なAPI呼び出しが可能です。リンクはhttps://github.com/Azure/azure-iot-sdks/tree/master/java – juvchan
です。はい、これを共有アクセスポリシーの作成に使用しようとしました。この目的のためのコード例とドキュメントは見つかりませんでした。だから私はhttpの残りのAPIで終わる。 1つを参照できますか?ありがとう – Sadaf