У меня возникла проблема: я не могу обновить столбец поиска с помощью Java. Я протестировал несколько вариантов, но ничего не работало. Ниже приведен код (тот же код, который я использую для других типов столбцов, и он там работает):
public static void main(String[] args) throws Exception {
DataverseController.updateColumnEMailMVPLookup(
"/tableWithDataForInput(GUID_of_row)",
"GUID_row_id_in_table_for_change",
token,
"https://myOrganiztion.crm4.dynamics.com/api/data/v9.2/",
"uniqa_mailtype"
);
}
public static void updateColumnEMailMVPLookup(
String value,
String row_id,
String token,
String url,
String columnForEditting
) throws IOException {
Map mapUpdate = new HashMap();
if ((value != null) && (value.trim().length() > 0)) {
mapUpdate.put(columnForEditting + "@odata.bind", "/" + value);
}
JSONObject obj = new JSONObject(mapUpdate);
String jsonString = obj.toString();
String uri = url + "nameTableForCorrect(" + row_id + ")";
URL urlFinal = new URL(uri);
HttpURLConnection httpURLConnection = (HttpURLConnection) urlFinal.openConnection();
httpURLConnection.setDoOutput(true);
httpURLConnection.setRequestMethod("PUT"); // PATCH back error
httpURLConnection.setRequestProperty("Authorization", "Bearer " + token);
httpURLConnection.setRequestProperty("Content-Type", "application/json");
httpURLConnection.setRequestProperty("Accept", "application/json");
try (OutputStream outputStream = httpURLConnection.getOutputStream()) {
outputStream.write(jsonString.getBytes());
outputStream.flush();
}
int responseCode = httpURLConnection.getResponseCode();
StringBuilder response = new StringBuilder();
if (responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
// Successful update, no content expected in response
System.out.println("Update successful.");
} else {
// Read the error response
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpURLConnection.getErrorStream()))) {
String line;
while ((line = bufferedReader.readLine()) != null) {
response.append(line);
}
}
System.err.println("Update failed: " + responseCode + " " + httpURLConnection.getResponseMessage());
System.err.println("Error response: " + response.toString());
String enf = "";
}
}
Если кто-нибудь сможет помочь с этим, я буду очень благодарен.
Я очень старался. На самом деле проблема в том, что он не поддерживает способ написания столбца поиска.
Ошибка:
Update failed: 400 Bad Request
Error response: {"error":{"code":"0x80048d19","message":"Error identified in Payload provided by the user for Entity :'', For more information on this error please follow this help link https://go.microsoft.com/fwlink/?linkid=2195293 ----> InnerException : Microsoft.OData.ODataException: An undeclared property 'uniqa_mailtype' which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values.\r\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadUndeclaredProperty(IODataJsonLightReaderResourceState resourceState, String propertyName, Boolean propertyWithValue)\r\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadPropertyWithoutValue(IODataJsonLightReaderResourceState resourceState, String propertyName)\r\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.c__DisplayClass9_0.b__0(PropertyParsingResult propertyParsingResult, String propertyName)\r\n at Microsoft.OData.JsonLight.ODataJsonLightDeserializer.ProcessProperty(PropertyAndAnnotationCollector propertyAndAnnotationCollector, Func`2 readPropertyAnnotationValue, Action`2 handleProperty)\r\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadResourceContent(IODataJsonLightReaderResourceState resourceState)\r\n at Microsoft.OData.JsonLight.ODataJsonLightReader.StartReadingResource()\r\n at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadResourceSetItemStart(PropertyAndAnnotationCollector propertyAndAnnotationCollector, SelectedPropertiesNode selectedProperties)\r\n at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadAtStartImplementationSynchronously(PropertyAndAnnotationCollector propertyAndAnnotationCollector)\r\n at Microsoft.OData.ODataReaderCore.ReadImplementation()\r\n at Microsoft.OData.ODataReaderCore.InterceptException[T](Func`1 action)\r\n at System.Web.OData.Formatter.Deserialization.ODataReaderExtensions.ReadResourceOrResourceSet(ODataReader reader)\r\n at Microsoft.Crm.Extensibility.CrmODataEntityDeserializer.Read(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext)\r\n at System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)."}}
Подробнее здесь: https://stackoverflow.com/questions/788 ... ing-java-8
Проблемы с обновлением столбца поиска Dataverse с использованием Java 8 ⇐ JAVA
Программисты JAVA общаются здесь
1722829584
Anonymous
У меня возникла проблема: я не могу обновить столбец поиска с помощью Java. Я протестировал несколько вариантов, но ничего не работало. Ниже приведен код (тот же код, который я использую для других типов столбцов, и он там работает):
public static void main(String[] args) throws Exception {
DataverseController.updateColumnEMailMVPLookup(
"/tableWithDataForInput(GUID_of_row)",
"GUID_row_id_in_table_for_change",
token,
"https://myOrganiztion.crm4.dynamics.com/api/data/v9.2/",
"uniqa_mailtype"
);
}
public static void updateColumnEMailMVPLookup(
String value,
String row_id,
String token,
String url,
String columnForEditting
) throws IOException {
Map mapUpdate = new HashMap();
if ((value != null) && (value.trim().length() > 0)) {
mapUpdate.put(columnForEditting + "@odata.bind", "/" + value);
}
JSONObject obj = new JSONObject(mapUpdate);
String jsonString = obj.toString();
String uri = url + "nameTableForCorrect(" + row_id + ")";
URL urlFinal = new URL(uri);
HttpURLConnection httpURLConnection = (HttpURLConnection) urlFinal.openConnection();
httpURLConnection.setDoOutput(true);
httpURLConnection.setRequestMethod("PUT"); // PATCH back error
httpURLConnection.setRequestProperty("Authorization", "Bearer " + token);
httpURLConnection.setRequestProperty("Content-Type", "application/json");
httpURLConnection.setRequestProperty("Accept", "application/json");
try (OutputStream outputStream = httpURLConnection.getOutputStream()) {
outputStream.write(jsonString.getBytes());
outputStream.flush();
}
int responseCode = httpURLConnection.getResponseCode();
StringBuilder response = new StringBuilder();
if (responseCode == HttpURLConnection.HTTP_NO_CONTENT) {
// Successful update, no content expected in response
System.out.println("Update successful.");
} else {
// Read the error response
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(httpURLConnection.getErrorStream()))) {
String line;
while ((line = bufferedReader.readLine()) != null) {
response.append(line);
}
}
System.err.println("Update failed: " + responseCode + " " + httpURLConnection.getResponseMessage());
System.err.println("Error response: " + response.toString());
String enf = "";
}
}
Если кто-нибудь сможет помочь с этим, я буду очень благодарен.
Я очень старался. На самом деле проблема в том, что он не поддерживает способ написания столбца поиска.
Ошибка:
Update failed: 400 Bad Request
Error response: {"error":{"code":"0x80048d19","message":"Error identified in Payload provided by the user for Entity :'', For more information on this error please follow this help link https://go.microsoft.com/fwlink/?linkid=2195293 ----> InnerException : Microsoft.OData.ODataException: An undeclared property 'uniqa_mailtype' which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values.\r\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadUndeclaredProperty(IODataJsonLightReaderResourceState resourceState, String propertyName, Boolean propertyWithValue)\r\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadPropertyWithoutValue(IODataJsonLightReaderResourceState resourceState, String propertyName)\r\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.c__DisplayClass9_0.b__0(PropertyParsingResult propertyParsingResult, String propertyName)\r\n at Microsoft.OData.JsonLight.ODataJsonLightDeserializer.ProcessProperty(PropertyAndAnnotationCollector propertyAndAnnotationCollector, Func`2 readPropertyAnnotationValue, Action`2 handleProperty)\r\n at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadResourceContent(IODataJsonLightReaderResourceState resourceState)\r\n at Microsoft.OData.JsonLight.ODataJsonLightReader.StartReadingResource()\r\n at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadResourceSetItemStart(PropertyAndAnnotationCollector propertyAndAnnotationCollector, SelectedPropertiesNode selectedProperties)\r\n at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadAtStartImplementationSynchronously(PropertyAndAnnotationCollector propertyAndAnnotationCollector)\r\n at Microsoft.OData.ODataReaderCore.ReadImplementation()\r\n at Microsoft.OData.ODataReaderCore.InterceptException[T](Func`1 action)\r\n at System.Web.OData.Formatter.Deserialization.ODataReaderExtensions.ReadResourceOrResourceSet(ODataReader reader)\r\n at Microsoft.Crm.Extensibility.CrmODataEntityDeserializer.Read(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext)\r\n at System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)."}}
Подробнее здесь: [url]https://stackoverflow.com/questions/78832665/problems-with-update-dataverse-lookup-column-using-java-8[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия