Question

Add Type Field on Odata

Hi Dear's, I need add the type fields to a contact by OData in C#

I'm Using the https://academy.bpmonline.com/documents/technic-sdk/7-8/working-bpmonline-objects-over-odata-protocol-using-http-request  example but when a want insert the 

new XElement(ds + "Name", Name),

I have a error in the request. I think that maybe is a lookuop. But don't know how insert that.

Regards, 

  // Creating a xml message containing data on the created object.
            var content = new XElement(dsmd + "properties",
                       //   new XElement(ds + "Type", "Customer"),
                      //    new XElement(ds + "Account", "XT Group"),
                            new XElement(ds + "Name", Name), new XElement(ds + "Type", Name),
                          new XElement(ds + "Dear", Dear));
            var entry = new XElement(atom + "entry",
                        new XElement(atom + "content",
                        new XAttribute("type", "application/xml"), content));
            Console.WriteLine(entry.ToString());
            // Creating a request to the service which will add a new object to the contacts collection.
            var request = (HttpWebRequest)HttpWebRequest.Create(serverUri + "ContactCollection/");
            request.Credentials = new NetworkCredential(userName, userPassword);
            request.Method = "POST";
            request.Accept = "application/atom+xml";
            request.ContentType = "application/atom+xml;type=entry";
            // Recording the xml message to the request stream.
            using (var writer = XmlWriter.Create(request.GetRequestStream()))
            {
                entry.WriteTo(writer);
            }
            // Receiving a response from the service regarding the operation implementation result.
            using (WebResponse response = request.GetResponse())
            {
                if (((HttpWebResponse)response).StatusCode == HttpStatusCode.Created)
                {
                    Console.WriteLine("\n" + response.ToString());
                }
            }

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Helvetica; background-color: #000000}
span.s1 {color: #0433ff}
span.s2 {color: #33a2bd}
span.s3 {color: #b4261a}
File attachments

Like

1 comments

The "Type" field is a lookup. You need to insert a GUID into it.

for example, 

new XElement(ds + "Type", new Guid("03a75490-53e6-df11-971b-001d60e938c6")),

You can read the account types with the following request

http://ApplicationName/0/ServiceModel/EntityDataService.svc/AccountType…

Show all comments