SELECT p.PartID, p.SupplierID FROM #parts p LEFT OUTER JOIN #TradeCodes t ON t.PartID = p.PartID WHERE t.TradeCode IS NULL
Dim wrResult As HttpWebResponse Try ' post customer details Dim sURL As String = _baseURL & "Customer" Dim WebRequest As WebRequest = HttpWebRequest.Create(sURL) WebRequest.ContentType = "application/json" WebRequest.Credentials = GetCredential(sURL) WebRequest.PreAuthenticate = True WebRequest.Method = "POST" Dim sJson As New StringBuilder sJson.Append("{") sJson.Append("""No"": ""XXX"",") sJson.Append("""Name"": ""FRED""") sJson.Append("}") Dim postData As Byte() Dim utf As New UTF8Encoding postData = utf.GetBytes(sJson.ToString) WebRequest.ContentLength = sJson.Length Using stream = WebRequest.GetRequestStream() stream.Write(postData, 0, postData.Length) End Using wrResult = WebRequest.GetResponse() ' CODE DOES NOT GET HERE ON FAILING REQUEST If Not wrResult.StatusCode = HttpStatusCode.Created Then Throw New Exception("Customer XXX not created in Dynamics.") End If wrResult.Close() Catch wex As WebException ' BAD REQUEST WEB EXCEPTION CAUGHT HERE BUT ERROR MESSAGE NOT EXPOSED aNYWHERE ???? End Try
"error": { "code": "Unknown", "message": "The record already exists. CorrelationId: 862fae85-f342-43a4-96e7-191f0fae561c." } }