Я попробовал код ниже:
Код: Выделить всё
product_record_id="7ec1fc08-fcdb-ee11-904d-00224803f3ee"
LookupTo="LookupTableName"
#Update table code
# Define the data to be posted
data_to_post = [
{
"id": product_id,
"Product_value@odata.bind": f"/{LookupTo}({product_record_id})"
}
# Add more dictionaries for additional records if needed
]
# Make the POST request
response = requests.post(post_url, json=data_to_post, headers=headers)
# Check if the request was successful
if response.status_code == 201: # 201 indicates success for POST request
print("Data successfully posted.")
else:
print("Error:", response.status_code)
print("Response:", response.text)
Код: Выделить всё
"value": [
{
"@odata.etag": "W/\"992\"",
"_owningbusinessunit_value": "",
"id": "7ec1fc08-fcdb-ee11-904d-00224803f3ee",
"statecode": 0,
"statuscode": 1,
"entityname": "Product",
}
InnerException: Microsoft.OData.ODataException: свойство
'Product_value', который содержит только аннотации свойств в полезных данных, но
ни одно значение свойства не объявлено как относящееся к типу 'Edm.Guid'. В OData только
свойства навигации и именованные потоки могут быть представлены как
свойства без значений.\r\n в
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, ActionMicrosoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadResourceContent(IODataJsonLightReaderResourceState
resourceState)\r\n в
Microsoft.OData.JsonLight.ODataJsonLightReader. StartReadingResource()\r\n
at
Microsoft.OData.JsonLight.ODataJsonLightReader.ReadResourceSetItemStart(PropertyAndAnnotationCollector
propertyAndAnnotationCollector, SelectedPropertiesNode
selectedProperties)\r\n
Поскольку я новичок в этом деле, буду благодарен за любую помощь.
Подробнее здесь: https://stackoverflow.com/questions/781 ... ing-python