Answered by:
Problems Passing Values to Web Api2

Question
-
User1122355199 posted
Hello everyone and thanks for the help in advance. I am trying to post values to a web api2 controller but am having problems with one of the values being passed. Here is the ajax:
var jqxhr = $.post('api/Claim/PostPaymenttoCharge/', { "ID:": $("#txtpaymentid").val(), "ClaimDetailID": claimdetailid, "PaymentAmount": amttoapply }
Here is the controller:
<HttpPost> <Route("api/Claim/PostPaymenttoCharge/")> Function PostPaymenttoCharge(<FromBody()> ByVal model As PatientPayment) Dim ID As Integer = model.ID Dim ClaimDetailID As Integer = model.ClaimDetailID Dim PaymentAmount As Double = model.PaymentAmount End Function
and here is the model:
Public Class PatientPayment Private _ID As Integer = 0 Private _MRNumber As String = "" Private _PatientFirstName As String = "" Private _PatientLastName As String = "" Private _PaymentAmount As Double = 0 Private _AppliedAmount As Double = 0 Private _AppliedAmountFormatted As String = "" Private _Balance As Double = 0 Private _BalanceFormatted As String = "" Private _PaymentAmountFormatted As String = "" Private _PaymentDate As DateTime Private _PaymentDateFormatted As String = "" Private _PaymentMethod As String = "" Private _PaymentPurpose As String = "" Private _CheckNumber As String = "" Private _Notes As String = "" Private _CreatedBy As String = "" Private _ClaimDetailID As Integer = 0 Public Property ID() As Integer Get 'Dim msg As New McLaughlinUtilities.MailUtility("hugh@kmcnetwork.com", "hugh@kmcnetwork.com", "", "", "Class GET", "Apply paymentID " & _ID, "", "HTML", "High") Return _ID End Get Set(value As Integer) _ID = value 'Dim msg As New McLaughlinUtilities.MailUtility("hugh@kmcnetwork.com", "hugh@kmcnetwork.com", "", "", "Class SET", "Apply paymentID " & _ID, "", "HTML", "High") End Set End Property Public Property MRNumber() As String Get Return _MRNumber End Get Set(value As String) _MRNumber = value End Set End Property Public Property PatientFirstName() As String Get Return _PatientFirstName End Get Set(value As String) _PatientFirstName = value End Set End Property Public Property PatientLastName() As String Get Return _PatientLastName End Get Set(value As String) _PatientLastName = value End Set End Property Public Property PaymentAmount() As Double Get Return _PaymentAmount End Get Set(value As Double) _PaymentAmount = value End Set End Property Public Property AppliedAmount() As Double Get Return _AppliedAmount End Get Set(value As Double) _AppliedAmount = value End Set End Property Public Property AppliedAmountFormatted() As String Get Return _AppliedAmountFormatted End Get Set(value As String) _AppliedAmountFormatted = value End Set End Property Public Property Balance() As Double Get Return _Balance End Get Set(value As Double) _Balance = value End Set End Property Public Property BalanceFormatted() As String Get Return _BalanceFormatted End Get Set(value As String) _BalanceFormatted = value End Set End Property Public Property PaymentAmountFormatted() As String Get Return _PaymentAmountFormatted End Get Set(value As String) _PaymentAmountFormatted = value End Set End Property Public Property PaymentDate() As DateTime Get Return _PaymentDate End Get Set(value As DateTime) _PaymentDate = value End Set End Property Public Property PaymentDateFormatted() As String Get Return _PaymentDateFormatted End Get Set(value As String) _PaymentDateFormatted = value End Set End Property Public Property PaymentMethod() As String Get Return _PaymentMethod End Get Set(value As String) _PaymentMethod = value End Set End Property Public Property PaymentPurpose() As String Get Return _PaymentPurpose End Get Set(value As String) _PaymentPurpose = value End Set End Property Public Property CheckNumber() As String Get Return _CheckNumber End Get Set(value As String) _CheckNumber = value End Set End Property Public Property Notes() As String Get Return _Notes End Get Set(value As String) _Notes = value End Set End Property Public Property CreatedBy() As String Get Return _CreatedBy End Get Set(value As String) _CreatedBy = value End Set End Property Public Property ClaimDetailID() As Integer Get Return _ClaimDetailID End Get Set(value As Integer) _ClaimDetailID = value End Set End Property End Class
The ClaimDetailID and PaymentAmount pass perfectly fine, but the ID does not. I have also tried passing literal values for the ID rather than picking it up programmatically and I have even tried passing a string of letters just to see if it would fail, but it does not, instead returning 0 each time. I'm really stuck on what the problem is. Any help would be appreciated.
Sunday, April 3, 2016 2:56 AM
Answers
-
User1122355199 posted
After banging my head my head for several hours, I found the extra semicolon in "ID:":, removed it and fixed. Thanks to all and sorry for any inconvenience.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, April 3, 2016 7:13 PM