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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Error while setting the Lookup Value

(0) ShareShare
ReportReport
Posted on by 60

Hi

i want to create a new contact when a specific property is change of Account entity, 

i ran into problem while setting the lookup value in web API create request

my request code is 

var Sdk = window.Sdk || {};

/**
* Request to execute a create operation
*/
debugger;
Sdk.CreateRequest = function (entityName, payload) {
this.etn = entityName;
this.payload = payload;
};
Sdk.CreateRequest.prototype.getMetadata = function () {
return {
boundParameter: null,
parameterTypes: {},
operationType: 2, // This is a CRUD operation. Use '0' for actions and '1' for functions
operationName: "Create",
};
};
// Construct a request object from the metadata
var payload = {
firstname: "Contact first name",
lastname : "Contact Last name",
cc_salutation : 100000000,
["ParentCustomerId@odata.bind"] : "/accounts("+id+")"
};


console.log("payload =>"+JSON.stringify(payload));

var createRequest = new Sdk.CreateRequest("contact", payload);

// Use the request object to execute the function
window.parent.Xrm.WebApi.online.execute(createRequest).then(
function (result) {
if (result.ok) {
alert("Created Successfully");
console.log("Status: %s %s", result.status, result.statusText);
// perform other operations as required;
}
},
function (error) {
alert("Failed "+error.message);
console.log(error.message);
// handle error conditions
}
);

but i have this error message

An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property 'ParentCustomerId' 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.
at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadUndeclaredProperty(IODataJsonLightReaderResourceState resourceState, String propertyName, Boolean propertyWithValue)
at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadPropertyWithoutValue(IODataJsonLightReaderResourceState resourceState, String propertyName)
at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.<>c__DisplayClass9_0.<ReadResourceContent>b__0(PropertyParsingResult propertyParsingResult, String propertyName)
at Microsoft.OData.JsonLight.ODataJsonLightDeserializer.ProcessProperty(PropertyAndAnnotationCollector propertyAndAnnotationCollector, Func`2 readPropertyAnnotationValue, Action`2 handleProperty)
at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadResourceContent(IODataJsonLightReaderResourceState resourceState)
at Microsoft.OData.JsonLight.ODataJsonLightReader.StartReadingResource()
at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadResourceSetItemStart(PropertyAndAnnotationCollector propertyAndAnnotationCollector, SelectedPropertiesNode selectedProperties)
at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadAtStartImplementationSynchronously(PropertyAndAnnotationCollector propertyAndAnnotationCollector)
at Microsoft.OData.ODataReaderCore.ReadImplementation()
at Microsoft.OData.ODataReaderCore.InterceptException[T](Func`1 action)
at System.Web.OData.Formatter.Deserialization.ODataReaderExtensions.ReadResourceOrResourceSet(ODataReader reader)
at System.Web.OData.Formatter.Deserialization.ODataResourceDeserializer.Read(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext)
at System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)

my lookup field value in payload is not empty, i have consoled the paylaod and i can see the lookup value

payload =>{"firstname":"Contact first name","lastname":"Contact Last name","cc_salutation":100000000,"ParentCustomerId@odata.bind":"/accounts({XXXXXX-XXX-XXXX})"}

Any help will be appreciated.

Thanks

I have the same question (0)
  • Suggested answer
    ajyendra Profile Picture
    1,738 on at

    parentcustomerid_account instead of ParentCustomerId

  • Bilal079 Profile Picture
    60 on at

    Hi @Ajyendra

    Thanks for your response

    i have tried this

    var payload = {

       firstname: "test111.",

       lastname : "lasttt",

       bbo_salutation : 100000000,

       ["parentcustomerid_account"] : "/accounts("+id+")"

    };

    and got this error

    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 'parentcustomerid_account'; however, a 'StartArray' node, a 'StartObject' node, or a 'PrimitiveValue' node with null value was expected.

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

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

      at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.<>c__DisplayClass9_0.<ReadResourceContent>b__0(PropertyParsingResult propertyParsingResult, String propertyName)

      at Microsoft.OData.JsonLight.ODataJsonLightDeserializer.ProcessProperty(PropertyAndAnnotationCollector propertyAndAnnotationCollector, Func`2 readPropertyAnnotationValue, Action`2 handleProperty)

      at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadResourceContent(IODataJsonLightReaderResourceState resourceState)

      at Microsoft.OData.JsonLight.ODataJsonLightReader.StartReadingResource()

      at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadResourceSetItemStart(PropertyAndAnnotationCollector propertyAndAnnotationCollector, SelectedPropertiesNode selectedProperties)

      at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadAtStartImplementationSynchronously(PropertyAndAnnotationCollector propertyAndAnnotationCollector)

      at Microsoft.OData.ODataReaderCore.ReadImplementation()

      at Microsoft.OData.ODataReaderCore.InterceptException[T](Func`1 action)

      at System.Web.OData.Formatter.Deserialization.ODataReaderExtensions.ReadResourceOrResourceSet(ODataReader reader)

      at System.Web.OData.Formatter.Deserialization.ODataResourceDeserializer.Read(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext)

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

  • Verified answer
    ajyendra Profile Picture
    1,738 on at

    var payload = {

      firstname: "test111.",

      lastname : "lasttt",

      bbo_salutation : 100000000,

      "parentcustomerid_account@odata.bind" : "/accounts("+id+")"

    }

    OR

    var payload = {

      firstname: "test111.",

      lastname : "lasttt",

      bbo_salutation : 100000000,

      parentcustomerid_account@odata.bind : "/accounts("+id+")"

    }

  • Bilal079 Profile Picture
    60 on at

    Thank you so much, it is working

    var payload = {

       firstname: "test111.",

       lastname : "lasttt",

       bbo_salutation : 100000000,

       "parentcustomerid_account@odata.bind" : "/accounts("+id+")"

    };

    Thanks again

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 180 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 123

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans