EBDN - Community - Question & Answers

  Thursday, 26 April 2018
  1 Replies
  1.5K Visits
0
Votes
Undo
I want create an object in Eb by standard web service.

I try this :

using (HttpClientHandler ch = new HttpClientHandler() { UseDefaultCredentials = true })
using (HttpClient client = new HttpClient(ch))
{
ObjectData od = new ObjectData();
od.CoverId = 113;
od.Attributes = new LinkList<AttributeData>();
od.Attributes.Items = new List<AttributeData>();
od.Attributes.Items.Add(new AttributeData() { AttributeId = 5, AttributeValue = new AttributeValue() {Value = "Test web service" } });

JavaScriptSerializer jss = new JavaScriptSerializer();
string presq = jss.Serialize(od);
StringContent spresq = new StringContent(presq);

using (HttpResponseMessage response = await client.PostAsync("http://jco-nb:8734/api/rs/v1/EB671_BRM/objects/00000000-0000-0000-0000-00000137E0C4", spresq))
using (HttpContent content = response.Content)
{
// ... Read the string.

resp = await content.ReadAsStringAsync();
}
}