web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Error while creating contact using dynamic crm api

(0) ShareShare
ReportReport
Posted on by

Hi,

I am new to Dynamic CRM. I am trying to create a contact which works fine as long as I pass firstname, lastname fields with api as payload but when i add email in the json payload it start throw exception.

Can someone please let me know if there is any documentation available for field name mapping for api.

Tx,

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    Here is the stack trace of error:

    An unexpected 'PrimitiveValue' node was found when reading from the JSON reader. A 'StartObject' node was expected.\\\",\\\"innererror\\\":{\\\"message\\\":\\\"An unexpected 'PrimitiveValue' node was found when reading from the JSON reader. A 'StartObject' node was expected.\\\",\\\"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.D365.ServicePlatform.Context.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func)\\\\r\\\\n   at Microsoft.D365.ServicePlatform.Context.ActivityLoggerExtensions.Execute[TResult](ILogger logger, ActivityType 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.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\\\\r\\\\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\\\\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.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\\\\r\\\\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\\\\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.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)\\\\r\\\\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\\\\r\\\\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()\\\"}}}\"","name":"StatusCodeError","stack":"StatusCodeError: 400 - \"{\\\"error\\\":{\\\"code\\\":\\\"0x0\\\",\\\"message\\\":\\\"An unexpected 'PrimitiveValue' node was found when reading from the JSON reader. A 'StartObject' node was expected.\\\",\\\"innererror\\\":{\\\"message\\\":\\\"An unexpected 'PrimitiveValue' node was found when reading from the JSON reader. A 'StartObject' node was expected.\\\",\\\"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.D365.ServicePlatform.Context.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func)\\\\r\\\\n   at Microsoft.D365.ServicePlatform.Context.ActivityLoggerExtensions.Execute[TResult](ILogger logger, ActivityType 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)

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Sachin,

    You can use CRM REST Builder tool to generate the web api request and even executye it there. This will ensure you have the right code and avoid any mapping issue if any.

    github.com/.../CRMRESTBuilder

    www.toplinestrategies.com/.../crm-rest-builder-useful-tool-working-crm-2016%E2%80%99s-web-api

    Hope this helps.

  • Mahendar Pal Profile Picture
    45,095 on at

    In addition to that you can also share your code here for checking,

  • Community Member Profile Picture
    on at

    Thanks Ravi. I managed to resolve the issue. There was some issue with my code but links you provided would definitely help me.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans