Python 3.x Microsoft Dynamics 365现场服务Web API:创建工单触发器;代码";:&引用;0x80040265“&引用;“讯息”:&引用;服务帐户是必需的。”;, HTTP POST在Microsoft Dynamics 365中创建新

Python 3.x Microsoft Dynamics 365现场服务Web API:创建工单触发器;代码";:&引用;0x80040265“&引用;“讯息”:&引用;服务帐户是必需的。”;, HTTP POST在Microsoft Dynamics 365中创建新,python-3.x,dynamics-crm,microsoft-dynamics,dynamics-365,dynamics-crm-webapi,Python 3.x,Dynamics Crm,Microsoft Dynamics,Dynamics 365,Dynamics Crm Webapi,Microsoft Dynamics 365现场服务Web API:创建工单触发器;代码";:&引用;0x80040265“&引用;“讯息”:&引用;服务帐户是必需的。”;, HTTP POST在Microsoft Dynamics 365中创建新工单-现场服务(空正文) 文章正文为空时收到错误 帖子正文包含msdyn_serviceaccount字段时收到错误 { “错误”:{ “代码”:“0x0”, “消息”:“验证输入参数时出错:Microsoft.OData.ODataExcep

Microsoft Dynamics 365现场服务Web API:创建工单触发器;代码";:&引用;0x80040265“&引用;“讯息”:&引用;服务帐户是必需的。”;, HTTP POST在Microsoft Dynamics 365中创建新工单-现场服务(空正文) 文章正文为空时收到错误 帖子正文包含msdyn_serviceaccount字段时收到错误
{
“错误”:{
“代码”:“0x0”,
“消息”:“验证输入参数时出错:Microsoft.OData.ODataException:尝试读取属性“msdyn_serviceaccount”的值时,发现具有非null值的“PrimitiveValue”节点;但是,应为具有null值的“StartArray”节点、“StartObject”节点或“PrimitiveValue”节点。\r\n
在Microsoft.OData.JsonLight.ODataJsonLightPropertyAndValueDeserializer.validateExpandedRestedResourceInfoPropertyValue(IJsonReader-jsonReader,Nullable`1 isCollection,String propertyName)\r\n
位于Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadPropertyWithValue(IODataJsonLightReaderResourceState,String propertyName,Boolean isDeltaResourceSet)\r\n
在Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.c_uuDisplayClass9_0.b_u0(PropertyParsinResult PropertyParsinResult,String propertyName)\r\n
在Microsoft.OData.JsonLight.ODataJsonLightDeserializer.ProcessProperty(PropertyAnandNotationCollector PropertyAnandNotationCollector,Func`2 ReadPropertyAnotationValue,Action`2 handleProperty)\r\n
位于Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadResourceContent(IODataJsonLightReaderResourceState)\r\n
位于Microsoft.OData.JsonLight.ODataJsonLightReader.StartReadingResource()\r\n
在Microsoft.OData.JsonLight.ODataJsonLightReader.ReadResourceSetItemStart(PropertyandNotationCollector PropertyandNotationCollector,SelectedPropertiesNodeSelectedProperties)中,位于
Microsoft.OData.JsonLight.ODataJsonLightReader.ReadAtStartImplementationSynchronously(PropertyandNotationCollector PropertyandNotationCollector)\r\n
位于Microsoft.OData.ODataReaderCore.ReadImplementation()\r\n
在Microsoft.OData.ODataReaderCore.InterceptException[T](函数'1操作)\r\n
位于System.Web.OData.Formatter.Deserialization.ODataReaderExtensions.ReadResourceOrResourceSet(ODataReader reader)\r\n
位于System.Web.OData.Formatter.Deserialization.ODataResourceSerializer.Read(ODataMessageReader,类型,ODataDeserializerContext readContext)\r\n
在System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(类型类型、流readStream、HttpContent内容、IFormatterLogger格式记录器)”中,
“内部错误”:{
“消息”:“验证输入参数时出错:Microsoft.OData.ODataException:尝试读取属性“msdyn_serviceaccount”的值时,发现具有非null值的“PrimitiveValue”节点;但是,应为具有null值的“StartArray”节点、“StartObject”节点或“PrimitiveValue”节点。\r\n
在Microsoft.OData.JsonLight.ODataJsonLightPropertyAndValueDeserializer.validateExpandedRestedResourceInfoPropertyValue(IJsonReader-jsonReader,Nullable`1 isCollection,String propertyName)\r\n
位于Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadPropertyWithValue(IODataJsonLightReaderResourceState,String propertyName,Boolean isDeltaResourceSet)\r\n
在Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.c_uuDisplayClass9_0.b_u0(PropertyParsinResult PropertyParsinResult,String propertyName)\r\n
在Microsoft.OData.JsonLight.ODataJsonLightDeserializer.ProcessProperty(PropertyAnandNotationCollector PropertyAnandNotationCollector,Func`2 ReadPropertyAnotationValue,Action`2 handleProperty)\r\n
位于Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadResourceContent(IODataJsonLightReaderResourceState)\r\n
位于Microsoft.OData.JsonLight.ODataJsonLightReader.StartReadingResource()\r\n
在Microsoft.OData.JsonLight.ODataJsonLightReader.ReadResourceSetItemStart(PropertyandNotationCollector PropertyandNotationCollector,selectedProperties节点selectedProperties)上
在Microsoft.OData.JsonLight.ODataJsonLightReader.ReadAtStartImplementationSynchronously(PropertyandNotationCollector PropertyandNotationCollector)\r\n
位于Microsoft.OData.ODataReaderCore.ReadImplementation()\r\n
在Microsoft.OData.ODataReaderCore.InterceptException[T](函数'1操作)\r\n
位于System.Web.OData.Formatter.Deserialization.ODataReaderExtensions.ReadResourceOrResourceSet(ODataReader reader)\r\n
位于System.Web.OData.Formatter.Deserialization.ODataResourceSerializer.Read(ODataMessageReader,类型,ODataDeserializerContext readContext)\r\n
在System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(类型类型、流readStream、HttpContent内容、IFormatterLogger格式记录器)”中,
“类型”:“Microsoft.Crm.CRMHTTPEException”,
“stacktrace”:“位于Microsoft.Crm.Extensibility.OData.CrmODataUtilities.ValidateInputParameters(ModelStateDictionary controllerModelState)\r\n
位于Microsoft.Crm.Extensibility.OData.EntityController.PostEntitySetImplementation(String&entitySetName,EdmEntityObject-entityObject)\r\n
在Microsoft.Crm.Extensibility.OData.CrmODataUtilities.c_uuuDisplayClass10_0`2.b_uu0()\r\n
在Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger记录器,EventId EventId,ActivityType ActivityType,Func`1 Func,IEnumerable`1 additionalCustomProperties)\r\n
在Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger记录器,XrmTelemetryActivityType activityType,Func`1 Func)上\r\n
在lambda_方法(闭包、对象、对象[])处\r\n
在System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.c\u DisplayClass10.b\u 9(对象实例,对象[]方法参数)\r\n
在System.Web.Http.C
import requests

url = "https://{{my-env_name}}.{{my_region}}.dynamics.com/api/data/v9.0/msdyn_workorders"

payload = "{\n   \n}"
headers = {
  'Accept': 'application/json',
  'OData-MaxVersion': '4.0',
  'OData-Version': '4.0',
  'If-None-Match': 'null',
  'Authorization': 'Bearer eyXXX',
  'Content-Type': 'application/json',
}

response = requests.request("POST", url, headers=headers, data = payload)

print(response.text.encode('utf8'))


{
    "error": {
        "code": "0x80040265",

        "message": "The Service Account is required.",

        "innererror": {
            "message": "The Service Account is required.",

            "type": "System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]",

            "stacktrace": "   at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.CreateInternal(Entity entity, InvocationContext invocationContext, CallerOriginToken callerOriginToken, WebServiceType serviceType, Boolean checkAdminMode, Dictionary`2 optionalParameters)\r\n

   at Microsoft.Crm.Extensibility.OData.CrmODataExecutionContext.CreateOrganizationResponse(Entity entity)\r\n

   at Microsoft.Crm.Extensibility.OData.CrmODataServiceDataProvider.CreateEdmEntity(CrmODataExecutionContext context, String edmEntityName, EdmEntityObject entityObject, Boolean isUpsert)\r\n

   at Microsoft.Crm.Extensibility.OData.EntityController.PostEntitySetImplementation(String& entitySetName, EdmEntityObject entityObject)\r\n

   at Microsoft.Crm.Extensibility.OData.CrmODataUtilities.<>c__DisplayClass10_0`2.<InvokeActionAndLogMetric>b__0()\r\n

   at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)\r\n

   at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)\r\n

   at lambda_method(Closure , Object , Object[] )\r\n

   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n

   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n

--- End of stack trace from previous location where exception was thrown ---\r\n

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n

--- End of stack trace from previous location where exception was thrown ---\r\n

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n

--- End of stack trace from previous location where exception was thrown ---\r\n

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
        }
    }
}
{
  "msdyn_serviceaccount": "{{an existing account id}}"
}

{
    "error": {

        "code": "0x0",


        "message": "An error occurred while validating input parameters: Microsoft.OData.ODataException: A 'PrimitiveValue' node with non-null value was found when trying to read the value of the property 'msdyn_serviceaccount'; however, a 'StartArray' node, a 'StartObject' node, or a 'PrimitiveValue' node with null value was expected.\r\n

   at Microsoft.OData.JsonLight.ODataJsonLightPropertyAndValueDeserializer.ValidateExpandedNestedResourceInfoPropertyValue(IJsonReader jsonReader, Nullable`1 isCollection, String propertyName)\r\n

   at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadPropertyWithValue(IODataJsonLightReaderResourceState resourceState, String propertyName, Boolean isDeltaResourceSet)\r\n

   at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.<>c__DisplayClass9_0.<ReadResourceContent>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 System.Web.OData.Formatter.Deserialization.ODataResourceDeserializer.Read(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext)\r\n

   at System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)",
        "innererror": {

            "message": "An error occurred while validating input parameters: Microsoft.OData.ODataException: A 'PrimitiveValue' node with non-null value was found when trying to read the value of the property 'msdyn_serviceaccount'; however, a 'StartArray' node, a 'StartObject' node, or a 'PrimitiveValue' node with null value was expected.\r\n

   at Microsoft.OData.JsonLight.ODataJsonLightPropertyAndValueDeserializer.ValidateExpandedNestedResourceInfoPropertyValue(IJsonReader jsonReader, Nullable`1 isCollection, String propertyName)\r\n

   at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadPropertyWithValue(IODataJsonLightReaderResourceState resourceState, String propertyName, Boolean isDeltaResourceSet)\r\n

   at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.<>c__DisplayClass9_0.<ReadResourceContent>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 System.Web.OData.Formatter.Deserialization.ODataResourceDeserializer.Read(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext)\r\n

   at System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)",
            "type": "Microsoft.Crm.CrmHttpException",
            "stacktrace": "   at Microsoft.Crm.Extensibility.OData.CrmODataUtilities.ValidateInputParameters(ModelStateDictionary controllerModelState)\r\n

   at Microsoft.Crm.Extensibility.OData.EntityController.PostEntitySetImplementation(String& entitySetName, EdmEntityObject entityObject)\r\n

   at Microsoft.Crm.Extensibility.OData.CrmODataUtilities.<>c__DisplayClass10_0`2.<InvokeActionAndLogMetric>b__0()\r\n

   at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)\r\n

   at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)\r\n

   at lambda_method(Closure , Object , Object[] )\r\n

   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n

   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n

   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()\r\n

--- End of stack trace from previous location where exception was thrown ---\r\n

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n

   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n

   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n

--- End of stack trace from previous location where exception was thrown ---\r\n

   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n

   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
        }
    }
}
{
  "msdyn_serviceaccount@odata.bind": "/accounts(guid)"
}
{
   "msdyn_serviceaccount@odata.bind": "/accounts(account_entity_guid_you_want_to_bind)",    
   "msdyn_pricelist@odata.bind": "/pricelevels(pricelevel_entity_guid_you_want_to_bind)",    
   "msdyn_systemstatus": "690970000",    
}