public PostReturn(APIObject[] theObjects, ET_Client theClient) { this.Message = ""; this.Status = true; this.MoreResults = false; string OverallStatus = string.Empty, RequestID = string.Empty; Result[] requestResults = new Result[0]; theClient.refreshToken(); using (var scope = new OperationContextScope(theClient.soapclient.InnerChannel)) { //Add oAuth token to SOAP header. XNamespace ns = "http://exacttarget.com"; var oauthElement = new XElement(ns + "oAuthToken", theClient.internalAuthToken); var xmlHeader = MessageHeader.CreateHeader("oAuth", "http://exacttarget.com", oauthElement); OperationContext.Current.OutgoingMessageHeaders.Add(xmlHeader); var httpRequest = new System.ServiceModel.Channels.HttpRequestMessageProperty(); OperationContext.Current.OutgoingMessageProperties.Add(System.ServiceModel.Channels.HttpRequestMessageProperty.Name, httpRequest); httpRequest.Headers.Add(HttpRequestHeader.UserAgent, theClient.SDKVersion); List<APIObject> lObjects = new List<APIObject>(); foreach (APIObject ao in theObjects) { lObjects.Add(this.TranslateObject(ao)); } requestResults = theClient.soapclient.Create(new CreateOptions(), lObjects.ToArray(), out RequestID, out OverallStatus); this.Status = true; this.Code = 200; this.MoreResults = false; this.Message = ""; if (OverallStatus != "OK") { this.Status = false; } if (requestResults.GetType() == typeof(CreateResult[]) && requestResults.Length > 0) { List<ResultDetail> results = new List<ResultDetail>(); foreach (CreateResult cr in requestResults) { ResultDetail detail = new ResultDetail(); if (cr.StatusCode != null) detail.StatusCode = cr.StatusCode; if (cr.StatusMessage != null) detail.StatusMessage = cr.StatusMessage; if (cr.NewObjectID != null) detail.NewObjectID = cr.NewObjectID; if (cr.Object != null) detail.Object = this.TranslateObject(cr.Object); detail.OrdinalID = cr.OrdinalID; detail.ErrorCode = cr.ErrorCode; detail.NewID = cr.NewID; results.Add(detail); } this.Results = results.ToArray(); } } }