Hello Guys,
I am facing an issue that how to set null value in the Lookup field using c# web api.
I am using following code--
address["field schema name"] = null;
Its working fine when i use 2011 endpoint service to update the null but not with the custom c# web api.
Your help would be a great help.
thanks
You cannot set null to lookup using web api.
Rather use DELETE verb for single valued navigation property.
yes folk, i have tried it and its not working and throwing the usual error "Object reference not set to an instance of an object" something like this which means its not accepting the either "" or null.
Hi partner,
Have you tried the suggestions? How is the situation now?
Best Regards
Leo
this field is already containing some so i want to remove that data from the field that's why i need to set it as null
Hello,
Why are you trying to specify this field is null ? If you have nothing to put in this field just delete the line. :)
(Maybe you will have some errors if specific development use this field after, but normally you have to handle this)
Hi partner,
You could try "" (empty) instead of null.
In addition, could you kindly share the error message?
Hope it helps.
Best Regards
Leo
Hi partner,
When using WebApi to update lookup field, we should add "@odata.bind" after field name.
You could refer to samples of using WebApi with C#.
Please try address["field name@odata.bind"] instead.
Hope it helps.
Best Regards
Leo
thanks for the response,
i am already using the @odata.bind in the schema name.
If i am passing the Guid of the record the its being saved in the CRM but when i try to set it null by sending the null string then its throwing the error.