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

get object guid

Former Member
Former Member
Hello
I created a object in MFiles and I need to return his web hyperlink.
The information from
kb.cloudvault.m-files.com/Default.aspx

1.1 Object Links
Object links are formed in the following fashion:
<M-Files Web base URL>/Default.aspx?#<vault GUID>/object/<object GUID>
For instance: myvault.com/Default.aspx
object/06717B8A-8D7A-4F40-B01H-037EBCF376BA/
Object links open M-Files Web in your default browser and display the targeted object in the listing area.



private static ObjectVersion CreateObjectInMFiles(string authToken, UploadInfo uploadInfo)
        {
            // Construct the URL.
            // For object creation the URL only specifies the type.
            string url = r_ServiceLink + "/objects/" + 0; //the 0 is for the document=0


            var createRequest = WebRequest.Create(url);
            createRequest.Method = "POST";
            createRequest.Headers["X-Authentication"] = authToken;

            // Create the creation info.
            // adding the properties
            var objectCreationInfo = new ObjectCreationInfo()
            {
                PropertyValues = new[]
                {
                    new PropertyValue()
                    {
                        PropertyDef = 100, // The built-in "Class" property Id.
TypedValue = new TypedValue()
                        {
                            DataType = MFDataType.Lookup,
                            Lookup = new Lookup()
                            {
                                Item = 23,
Version = -1 // Work around the bug detailed below.
}
                        }
                    },
                    new PropertyValue()
                    {
                        PropertyDef = 0, // The built-in "Name or Title" property Id.
TypedValue = new TypedValue()
                        {
                            DataType = MFDataType.Text,
                            Value = "Hello7" // the text for the "Name or Title"
}
                    },
                    new PropertyValue()
                    {
                        PropertyDef = 1087,
TypedValue = new TypedValue()
                        {
                            DataType = MFDataType.Date,
                            Value = System.DateTime.Now
}
                    }

                }, //add the properties
                Files = new[] { uploadInfo } // add the file to the object
            };

            // Send the creation info to the server.
            // Use JSON serializer to serialize it to the request stream.
            var infoSerializer = new DataContractJsonSerializer(typeof(ObjectCreationInfo));
            infoSerializer.WriteObject(createRequest.GetRequestStream(), objectCreationInfo);

            // Now get the response.
            var createResponse = createRequest.GetResponse();

            ///
            var settings = new DataContractJsonSerializerSettings();
            settings.DateTimeFormat = new System.Runtime.Serialization.DateTimeFormat("yyyy-MM-dd'T'HH:mm:ssZ");
            ///
            var serializer = new DataContractJsonSerializer(typeof(ObjectVersion), settings);
           
            var objectVersion = (ObjectVersion)serializer.ReadObject(createResponse.GetResponseStream());

            // Return the newly created object.
            return objectVersion;
        }


My question is -
How I can get the object Guid ?
(I using REST )