This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

C# REST API Setting MultiSelectLookup

Former Member
Former Member
Hey all. I've been doing some searching through the forums but I haven't really found a simple solution to my problem. All I am trying to do is set a multi select drop down list in M-Files through the REST API. When I run the below code I get a 500 error when posting to the server, meaning I have something wrong. This happens ONLY when a customer number is defined. I am using the same C# files provided in the samples I just renamed it to MFilesRepository.

Any help would be appreciated.



public void UploadFile(Stream stream, string fileName, int databaseId, ref MFilesRepository mFilesRepo, string customerNumber)
{
            List<PropertyValue> properties = new List<PropertyValue>();

            properties.Add(new PropertyValue() { PropertyDef = 100, TypedValue = new TypedValue() { DataType = MFDataType.Lookup, Lookup = new Lookup() { Item = 293, Version = -1 } } }); // Class
            properties.Add(new PropertyValue() { PropertyDef = 0, TypedValue = new TypedValue() { Value = fileName, DataType = MFDataType.Text } }); // I'm a document
            properties.Add(new PropertyValue() { PropertyDef = 1561, TypedValue = new TypedValue() { Value = databaseId, DataType = MFDataType.Integer } }); // Associated database id

            if (!String.IsNullOrEmpty(customerNumber))
            {
                List<Lookup> lookups = new List<Lookup>();
                lookups.Add(new Lookup() { Version = -1,  Item = int.Parse(customerNumber) });
                properties.Add(new PropertyValue() { PropertyDef = 1229, TypedValue = new TypedValue() { DataType = MFDataType.MultiSelectLookup, Lookups = lookups.ToArray() } });
            }

            mFilesRepo.CreateObject(0, properties.ToArray(), stream, fileName);
}